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;
193 in_rate * (int64_t)phase_count, INT32_MAX / 2))
240 if (compensation_distance < 0)
242 if (!compensation_distance && sample_delta)
246 #if FF_API_RESAMPLE_CLOSE_OPEN
250 int restore_matrix = 0;
255 if (fifo_samples > 0) {
279 if (restore_matrix) {
291 if (fifo_samples > 0) {
305 if (compensation_distance) {
307 (int64_t)sample_delta / compensation_distance;
319 int *consumed,
int src_size,
int dst_size,
int update_ctx,
320 int nearest_neighbour)
332 if (nearest_neighbour) {
333 uint64_t index2 = ((uint64_t)index) << 32;
335 dst_size =
FFMIN(dst_size,
336 (src_size-1-index) * (int64_t)c->
src_incr /
340 for(dst_index = 0; dst_index < dst_size; dst_index++) {
345 dst_index = dst_size;
348 index += (frac + dst_index * (int64_t)dst_incr_frac) / c->
src_incr;
349 frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->
src_incr;
351 for (dst_index = 0; dst_index < dst_size; dst_index++) {
360 frac += dst_incr_frac;
366 if (dst_index + 1 == compensation_distance) {
367 compensation_distance = 0;
379 if (compensation_distance) {
380 compensation_distance -= dst_index;
381 if (compensation_distance <= 0)
395 int ch, in_samples, in_leftover, consumed = 0, out_samples = 0;
409 }
else if (in_leftover <= c->final_padding_samples) {
427 memset(c->
buffer->
data[ch] + bps * i, 0, bps);
445 if (in_leftover > i) {
446 memcpy(c->
buffer->
data[ch] + bps * (in_leftover + i),
447 c->
buffer->
data[ch] + bps * (in_leftover - i - 1),
450 memset(c->
buffer->
data[ch] + bps * (in_leftover + i),
464 INT_MAX, 0, nearest_neighbour);
479 if (out_samples < 0) {
488 av_dlog(c->
avr,
"resampled %d in + %d leftover to %d out + %d leftover\n",