[MPlayer-dev-eng] scaletempo speedup, listen-test-request
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Nov 18 16:02:49 CET 2007
Hello,
On Sun, Nov 18, 2007 at 01:16:42PM +0100, A Mennucc wrote:
[...]
> ---- swing (Michael Bouble) - voice and contrabass
> -- speed 1.21, 0.83
> [O] is quite fine, but
> [P] adds a lot of tremolo
> --
Can you make that file available to me? If I have some good samples I
might be able to optimize it without changing quality much.
Attached is also a more readable/updated to SVN version of the patch.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libaf/af_scaletempo.c
===================================================================
--- libaf/af_scaletempo.c (revision 25097)
+++ libaf/af_scaletempo.c (working copy)
@@ -69,7 +69,6 @@
void* buf_pre_corr;
void* table_window;
int (*best_overlap_offset)(struct af_scaletempo_s* s);
- short shift_corr;
// command line
float scale_nominal;
float ms_stride;
@@ -151,7 +150,8 @@
static int best_overlap_offset_s16(af_scaletempo_t* s)
{
- int32_t *pw, *ppc;
+ uint16_t *pw;
+ int16_t *ppc;
int16_t *po, *search_start;
int32_t best_corr = INT_MIN;
int best_off = 0;
@@ -162,17 +162,20 @@
po += s->num_channels;
ppc = s->buf_pre_corr;
for (i=s->num_channels; i<s->samples_overlap; i++) {
- *ppc++ = ( *pw++ * *po++ ) >> 15;
+ *ppc++ = ( *pw++ * *po++ ) >> 16;
}
search_start = (int16_t*)s->buf_queue + s->num_channels;
for (off=0; off<s->frames_search; off++) {
- int32_t corr = 0;
+ int64_t corr = 0;
int16_t* ps = search_start;
ppc = s->buf_pre_corr;
- for (i=s->num_channels; i<s->samples_overlap; i++) {
- corr += ( *ppc++ * *ps++ ) >> s->shift_corr;
- }
+ ppc += s->samples_overlap - s->num_channels;
+ ps += s->samples_overlap - s->num_channels;
+ i = -(s->samples_overlap - s->num_channels);
+ do {
+ corr += ppc[i] * ps[i];
+ } while (++i < 0);
if (corr > best_corr) {
best_corr = corr;
best_off = off;
@@ -364,21 +367,20 @@
if (use_int) {
int64_t t = frames_overlap;
int32_t n = 8589934588LL / (t * t); // 4 * (2^31 - 1) / t^2
- int32_t* pw;
- s->buf_pre_corr = realloc(s->buf_pre_corr, s->bytes_overlap * 2);
- s->table_window = realloc(s->table_window, s->bytes_overlap * 2 - nch * bps * 2);
+ uint16_t* pw;
+ s->buf_pre_corr = realloc(s->buf_pre_corr, s->bytes_overlap);
+ s->table_window = realloc(s->table_window, s->bytes_overlap - nch * bps);
if(!s->buf_pre_corr && !s->table_window) {
af_msg(AF_MSG_FATAL, "[scaletempo] Out of memory\n");
return AF_ERROR;
}
pw = s->table_window;
for (i=1; i<frames_overlap; i++) {
- int32_t v = ( i * (t - i) * n ) >> 15;
+ uint16_t v = ( i * (t - i) * n ) >> 15;
for (j=0; j<nch; j++) {
*pw++ = v;
}
}
- s->shift_corr = av_log2( 2*(s->samples_overlap - nch) - 1 );
s->best_overlap_offset = best_overlap_offset_s16;
} else {
float* pw;
More information about the MPlayer-dev-eng
mailing list