diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-01-15 22:17:11 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-01-15 22:17:11 +0000 |
commit | dc8b9c7e2b3f6af062998d9d969c58b267f103a7 (patch) | |
tree | f38855c37e7b5c39df78b7467adb6a13da206aec /usr.bin/aucat | |
parent | bf7266dfb88caa7ad92482338bd98c199493cf1e (diff) |
Fix resampling algorithm to always produce integer block sizes.
Diffstat (limited to 'usr.bin/aucat')
-rw-r--r-- | usr.bin/aucat/aproc.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c index ba58b258414..13012ff56ea 100644 --- a/usr.bin/aucat/aproc.c +++ b/usr.bin/aucat/aproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.c,v 1.45 2010/01/14 17:57:47 ratchov Exp $ */ +/* $OpenBSD: aproc.c,v 1.46 2010/01/15 22:17:10 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -1247,10 +1247,12 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) #ifdef DEBUG if (debug_level >= 4) { aproc_dbg(p); - dbg_puts(": resamp starting ifr = "); + dbg_puts(": resamp starting diff = "); + dbg_puti(diff); + dbg_puts(", ifr = "); dbg_putu(ifr); dbg_puts(", ofr = "); - dbg_puti(ofr); + dbg_putu(ofr); dbg_puts(" fr\n"); } #endif @@ -1266,7 +1268,7 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) } diff += oblksz; ifr--; - } else { + } else if (diff > 0) { if (ofr == 0) break; ctx = ctxbuf; @@ -1278,6 +1280,18 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) } diff -= iblksz; ofr--; + } else { + if (ifr == 0 || ofr == 0) + break; + ctx_start ^= 1; + ctx = ctxbuf + ctx_start; + for (c = inch; c > 0; c--) { + *ctx = *odata++ = *idata++; + ctx += RESAMP_NCTX; + } + ifr--; + ofr--; + diff += oblksz - iblksz; } } p->u.resamp.diff = diff; @@ -1285,10 +1299,12 @@ resamp_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) #ifdef DEBUG if (debug_level >= 4) { aproc_dbg(p); - dbg_puts(": resamp done ifr = "); + dbg_puts(": resamp done delta = "); + dbg_puti(diff); + dbg_puts(", ifr = "); dbg_putu(ifr); dbg_puts(", ofr = "); - dbg_puti(ofr); + dbg_putu(ofr); dbg_puts(" fr\n"); } #endif |