diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-02-28 20:22:16 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-02-28 20:22:16 +0000 |
commit | 36d220ff6abcc3e97bd4771a7af128788d9bb5de (patch) | |
tree | 0e88e954717de2791aa033c372878fd2da049d2a /pjmedia/include | |
parent | dd6c9843dfaac34944c391437167d2401936ef30 (diff) |
Modify WSOLA discard to support erasing frame from non-contiguous buffer
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1827 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia/include')
-rw-r--r-- | pjmedia/include/pjmedia/types.h | 26 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/wsola.h | 28 |
2 files changed, 44 insertions, 10 deletions
diff --git a/pjmedia/include/pjmedia/types.h b/pjmedia/include/pjmedia/types.h index 49a4c25e..fe3b2349 100644 --- a/pjmedia/include/pjmedia/types.h +++ b/pjmedia/include/pjmedia/types.h @@ -190,7 +190,7 @@ typedef struct pjmedia_sock_info PJ_INLINE(void) pjmedia_zero_samples(pj_int16_t *samples, unsigned count) { #if 1 - pj_bzero(samples, count*sizeof(pj_int16_t)); + pj_bzero(samples, (count<<1)); #elif 0 unsigned i; for (i=0; i<count; ++i) samples[i] = 0; @@ -212,7 +212,7 @@ PJ_INLINE(void) pjmedia_copy_samples(pj_int16_t *dst, const pj_int16_t *src, unsigned count) { #if 1 - pj_memcpy(dst, src, count*sizeof(pj_int16_t)); + pj_memcpy(dst, src, (count<<1)); #elif 0 unsigned i; for (i=0; i<count; ++i) dst[i] = src[i]; @@ -226,6 +226,28 @@ PJ_INLINE(void) pjmedia_copy_samples(pj_int16_t *dst, const pj_int16_t *src, /** + * This is a general purpose function to copy samples from/to buffers with + * equal size. Since this function is needed by many parts of the library, + * by putting this functionality in one place, it enables some. + * clever people to optimize this function. + */ +PJ_INLINE(void) pjmedia_move_samples(pj_int16_t *dst, const pj_int16_t *src, + unsigned count) +{ +#if 1 + pj_memmove(dst, src, (count<<1)); +#elif 0 + unsigned i; + for (i=0; i<count; ++i) dst[i] = src[i]; +#else + unsigned i; + count >>= 1; + for (i=0; i<count; ++i) + ((pj_int32_t*)dst)[i] = ((pj_int32_t*)src)[i]; +#endif +} + +/** * @} */ diff --git a/pjmedia/include/pjmedia/wsola.h b/pjmedia/include/pjmedia/wsola.h index 86daf363..9592db38 100644 --- a/pjmedia/include/pjmedia/wsola.h +++ b/pjmedia/include/pjmedia/wsola.h @@ -58,7 +58,13 @@ enum pjmedia_wsola_option /** * Specify that the WSOLA will not be used for PLC. */ - PJMEDIA_WSOLA_NO_PLC = 2 + PJMEDIA_WSOLA_NO_PLC = 2, + + /** + * Specify that the WSOLA will not be used to discard frames in + * non-contiguous buffer. + */ + PJMEDIA_WSOLA_NO_DISCARD = 4 }; @@ -129,13 +135,17 @@ PJ_DECL(pj_status_t) pjmedia_wsola_generate(pjmedia_wsola *wsola, /** * Compress or compact the specified buffer by removing some audio samples - * from the buffer, without altering the pitch. + * from the buffer, without altering the pitch. For this function to work, + * total length of the buffer must be more than twice \a erase_cnt. * * @param wsola WSOLA session. - * @param buf Pointer to buffer. For this function to work, the buffer - * must contain more than twice \a erase_cnt number of - * samples. - * @param buf_cnt Number of samples in the buffer. + * @param buf1 Pointer to buffer. + * @param buf1_cnt Number of samples in the buffer. + * @param buf2 Pointer to second buffer, if the buffer is not + * contiguous. Otherwise this parameter must be NULL. + * @param buf2_cnt Number of samples in the second buffer, if the buffer + * is not contiguous. Otherwise this parameter should be + * zero. * @param erase_cnt On input, specify the number of samples to be erased. * This function may erase more or less than the requested * number, and the actual number of samples erased will be @@ -146,8 +156,10 @@ PJ_DECL(pj_status_t) pjmedia_wsola_generate(pjmedia_wsola *wsola, * of the parameters are not valid. */ PJ_DECL(pj_status_t) pjmedia_wsola_discard(pjmedia_wsola *wsola, - short buf[], - unsigned buf_cnt, + short buf1[], + unsigned buf1_cnt, + short buf2[], + unsigned buf2_cnt, unsigned *erase_cnt); |