31 #define CONFIG_RESAMPLE_DBL
33 #undef CONFIG_RESAMPLE_DBL
36 #define CONFIG_RESAMPLE_FLT
38 #undef CONFIG_RESAMPLE_FLT
41 #define CONFIG_RESAMPLE_S32
43 #undef CONFIG_RESAMPLE_S32
58 for (i = 1; v != lastv; i++) {
74 const int center = (tap_count - 1) / 2;
76 tab =
av_malloc(tap_count *
sizeof(*tab));
80 for (ph = 0; ph < phase_count; ph++) {
82 for (i = 0; i < tap_count; i++) {
83 x =
M_PI * ((double)(i - center) - (double)ph / phase_count) *
factor;
89 x = fabs(((
double)(i - center) - (
double)ph / phase_count) * factor);
90 if (x < 1.0) y = 1 - 3 * x*x + 2 * x*x*x + d * ( -x*x + x*x*x);
91 else y = d * (-4 + 8 * x - 5 * x*x + x*x*x);
95 w = 2.0 * x / (factor * tap_count) +
M_PI;
96 y *= 0.3635819 - 0.4891775 * cos( w) +
97 0.1365995 * cos(2 * w) -
98 0.0106411 * cos(3 * w);
101 w = 2.0 * x / (factor * tap_count *
M_PI);
110 for (i = 0; i < tap_count; i++)
111 tab[i] = tab[i] / norm;
191 in_rate * (int64_t)phase_count, INT32_MAX / 2))
238 if (compensation_distance < 0)
240 if (!compensation_distance && sample_delta)
244 #if FF_API_RESAMPLE_CLOSE_OPEN
248 int restore_matrix = 0;
253 if (fifo_samples > 0) {
277 if (restore_matrix) {
289 if (fifo_samples > 0) {
303 if (compensation_distance) {
305 (int64_t)sample_delta / compensation_distance;
317 int *consumed,
int src_size,
int dst_size,
int update_ctx,
318 int nearest_neighbour)
330 if (nearest_neighbour) {
331 uint64_t index2 = ((uint64_t)index) << 32;
333 dst_size =
FFMIN(dst_size,
334 (src_size-1-index) * (int64_t)c->
src_incr /
338 for(dst_index = 0; dst_index < dst_size; dst_index++) {
343 dst_index = dst_size;
346 index += (frac + dst_index * (int64_t)dst_incr_frac) / c->
src_incr;
347 frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->
src_incr;
349 for (dst_index = 0; dst_index < dst_size; dst_index++) {
358 frac += dst_incr_frac;
364 if (dst_index + 1 == compensation_distance) {
365 compensation_distance = 0;
377 if (compensation_distance) {
378 compensation_distance -= dst_index;
379 if (compensation_distance <= 0)
393 int ch, in_samples, in_leftover, consumed = 0, out_samples = 0;
407 }
else if (in_leftover <= c->final_padding_samples) {
425 memset(c->
buffer->
data[ch] + bps * i, 0, bps);
443 if (in_leftover > i) {
444 memcpy(c->
buffer->
data[ch] + bps * (in_leftover + i),
445 c->
buffer->
data[ch] + bps * (in_leftover - i - 1),
448 memset(c->
buffer->
data[ch] + bps * (in_leftover + i),
462 INT_MAX, 0, nearest_neighbour);
477 if (out_samples < 0) {
486 av_dlog(c->
avr,
"resampled %d in + %d leftover to %d out + %d leftover\n",