clarified buffer rules in bw_src*
This commit is contained in:
parent
12a574c07d
commit
262d4f9a5d
1
TODO
1
TODO
@ -39,7 +39,6 @@ code:
|
|||||||
* check assumptions w.r.t. usage of math functions
|
* check assumptions w.r.t. usage of math functions
|
||||||
* sample rate-constant coeffs? (pan case)
|
* sample rate-constant coeffs? (pan case)
|
||||||
* sr-dependent vs cr-dependent coeffs? see synth poly example
|
* sr-dependent vs cr-dependent coeffs? see synth poly example
|
||||||
* src x != y?
|
|
||||||
|
|
||||||
build system:
|
build system:
|
||||||
* single header generation (vs modules in bwp... to think about)
|
* single header generation (vs modules in bwp... to think about)
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
* C-style arrays as arguments.</li>
|
* C-style arrays as arguments.</li>
|
||||||
* <li>Removed usage of reserved identifiers.</li>
|
* <li>Removed usage of reserved identifiers.</li>
|
||||||
* <li>Removed useless computation when upsampling.</li>
|
* <li>Removed useless computation when upsampling.</li>
|
||||||
|
* <li>Clarified that the same buffer cannot be used for both input and
|
||||||
|
* output.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </li>
|
* </li>
|
||||||
* <li>Version <strong>0.6.0</strong>:
|
* <li>Version <strong>0.6.0</strong>:
|
||||||
@ -102,7 +104,7 @@ static inline void bw_src_reset_state(const bw_src_coeffs *BW_RESTRICT coeffs, b
|
|||||||
*
|
*
|
||||||
* #### bw_src_process()
|
* #### bw_src_process()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *x, float *y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
|
static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes at most the first `n_in_samples` of the input buffer `x` and
|
* Processes at most the first `n_in_samples` of the input buffer `x` and
|
||||||
* fills the output buffer `y` with at most `n_out_samples` using `coeffs`,
|
* fills the output buffer `y` with at most `n_out_samples` using `coeffs`,
|
||||||
@ -112,9 +114,11 @@ static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_sr
|
|||||||
* number of consumed input samples and generated output samples,
|
* number of consumed input samples and generated output samples,
|
||||||
* respectively.
|
* respectively.
|
||||||
*
|
*
|
||||||
|
* `x` and `y` must point to different buffers.
|
||||||
|
*
|
||||||
* #### bw_src_process_multi()
|
* #### bw_src_process_multi()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
|
static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes at most the first `n_in_samples[i]` of each input buffer `x[i]`
|
* Processes at most the first `n_in_samples[i]` of each input buffer `x[i]`
|
||||||
* and fills the corresponding output buffer `y[i]` with at most
|
* and fills the corresponding output buffer `y[i]` with at most
|
||||||
@ -125,6 +129,8 @@ static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs,
|
|||||||
* contain the actual number of consumed input samples and generated output
|
* contain the actual number of consumed input samples and generated output
|
||||||
* samples, respectively, for each of the `n_channels` input/output buffer
|
* samples, respectively, for each of the `n_channels` input/output buffer
|
||||||
* couples.
|
* couples.
|
||||||
|
*
|
||||||
|
* A given buffer cannot be used both as an input and output buffer.
|
||||||
* }}} */
|
* }}} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -200,7 +206,7 @@ static inline void bw_src_reset_state(const bw_src_coeffs *BW_RESTRICT coeffs, b
|
|||||||
state->xz3 = x_0;
|
state->xz3 = x_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *x, float *y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
|
static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
if (coeffs->k < 0) {
|
if (coeffs->k < 0) {
|
||||||
@ -267,7 +273,7 @@ static inline void bw_src_process(const bw_src_coeffs *BW_RESTRICT coeffs, bw_sr
|
|||||||
*n_out_samples = j;
|
*n_out_samples = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
|
static inline void bw_src_process_multi(const bw_src_coeffs *BW_RESTRICT coeffs, bw_src_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t n_channels, size_t *BW_RESTRICT n_in_samples, size_t *BW_RESTRICT n_out_samples) {
|
||||||
for (size_t i = 0; i < n_channels; i++)
|
for (size_t i = 0; i < n_channels; i++)
|
||||||
bw_src_process(coeffs, state[i], x[i], y[i], n_in_samples + i, n_out_samples + i);
|
bw_src_process(coeffs, state[i], x[i], y[i], n_in_samples + i, n_out_samples + i);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
* <li>Added overladed C++ <code>process()</code> function taking
|
* <li>Added overladed C++ <code>process()</code> function taking
|
||||||
* C-style arrays as arguments.</li>
|
* C-style arrays as arguments.</li>
|
||||||
* <li>Removed usage of reserved identifiers.</li>
|
* <li>Removed usage of reserved identifiers.</li>
|
||||||
|
* <li>Clarified that the same buffer cannot be used for both input and
|
||||||
|
* output.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </li>
|
* </li>
|
||||||
* <li>Version <strong>0.6.0</strong>:
|
* <li>Version <strong>0.6.0</strong>:
|
||||||
@ -109,7 +111,7 @@ static inline void bw_src_int_reset_state(const bw_src_int_coeffs *BW_RESTRICT c
|
|||||||
*
|
*
|
||||||
* #### bw_src_int_process()
|
* #### bw_src_int_process()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *x, float *y, size_t n_in_samples);
|
static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t n_in_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes the first `n_in_samples` of the input buffer `x` and fills the
|
* Processes the first `n_in_samples` of the input buffer `x` and fills the
|
||||||
* output buffer `y` using `coeffs`, while using and updating `state`.
|
* output buffer `y` using `coeffs`, while using and updating `state`.
|
||||||
@ -118,11 +120,13 @@ static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coe
|
|||||||
* `n_in_samples` if `ratio` is positive, otherwise at most `n_in_samples`
|
* `n_in_samples` if `ratio` is positive, otherwise at most `n_in_samples`
|
||||||
* divided by `-ratio` and then rounded towards positive infinity.
|
* divided by `-ratio` and then rounded towards positive infinity.
|
||||||
*
|
*
|
||||||
|
* `x` and `y` must point to different buffers.
|
||||||
|
*
|
||||||
* Returns the number of generated output samples.
|
* Returns the number of generated output samples.
|
||||||
*
|
*
|
||||||
* #### bw_src_int_process_multi()
|
* #### bw_src_int_process_multi()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples);
|
static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes the first `n_in_samples` of the `n_channels` input buffers `x`
|
* Processes the first `n_in_samples` of the `n_channels` input buffers `x`
|
||||||
* and fills the `n_channels` output buffers `y` using `coeffs`, while using
|
* and fills the `n_channels` output buffers `y` using `coeffs`, while using
|
||||||
@ -133,6 +137,8 @@ static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT
|
|||||||
* `n_in_samples` divided by `-ratio` and then rounded towards positive
|
* `n_in_samples` divided by `-ratio` and then rounded towards positive
|
||||||
* infinity.
|
* infinity.
|
||||||
*
|
*
|
||||||
|
* A given buffer cannot be used both as an input and output buffer.
|
||||||
|
*
|
||||||
* `n` is filled with the number of generated output samples for each output
|
* `n` is filled with the number of generated output samples for each output
|
||||||
* buffer, if not `NULL`.
|
* buffer, if not `NULL`.
|
||||||
* }}} */
|
* }}} */
|
||||||
@ -204,7 +210,7 @@ static inline void bw_src_int_reset_state(const bw_src_int_coeffs *BW_RESTRICT c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *x, float *y, size_t n_in_samples) {
|
static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT state, const float *BW_RESTRICT x, float *BW_RESTRICT y, size_t n_in_samples) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (coeffs->ratio < 0) {
|
if (coeffs->ratio < 0) {
|
||||||
for (size_t i = 0; i < n_in_samples; i++) {
|
for (size_t i = 0; i < n_in_samples; i++) {
|
||||||
@ -240,7 +246,7 @@ static inline size_t bw_src_int_process(const bw_src_int_coeffs *BW_RESTRICT coe
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples) {
|
static inline void bw_src_int_process_multi(const bw_src_int_coeffs *BW_RESTRICT coeffs, bw_src_int_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *BW_RESTRICT x, float *BW_RESTRICT const *BW_RESTRICT y, size_t *BW_RESTRICT n, size_t n_channels, size_t n_in_samples) {
|
||||||
if (n != NULL)
|
if (n != NULL)
|
||||||
for (size_t i = 0; i < n_channels; i++)
|
for (size_t i = 0; i < n_channels; i++)
|
||||||
n[i] = bw_src_int_process(coeffs, state[i], x[i], y[i], n_in_samples);
|
n[i] = bw_src_int_process(coeffs, state[i], x[i], y[i], n_in_samples);
|
||||||
|
Loading…
Reference in New Issue
Block a user