mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
resample-peaks: fix peaks resampler
Keep separate variable to check if we searched a complete chunk.
This commit is contained in:
parent
0a27040c9a
commit
a331779a28
2 changed files with 8 additions and 10 deletions
|
|
@ -46,18 +46,16 @@ static void impl_peaks_process(struct resample *r, int channel,
|
|||
{
|
||||
struct peaks_data *pd = r->data;
|
||||
float *s = src, *d = dst;
|
||||
int i, o, end;
|
||||
int i, o, end, chunk;
|
||||
|
||||
i = ((uint64_t) pd->o_count * r->i_rate) / r->o_rate;
|
||||
i = i > pd->i_count ? i - pd->i_count : 0;
|
||||
o = 0;
|
||||
o = i = 0;
|
||||
|
||||
while (i < *in_len && o < *out_len) {
|
||||
end = ((uint64_t) (pd->o_count + 1) * r->i_rate) / r->o_rate;
|
||||
end = ((uint64_t) (pd->o_count + 1) * r->i_rate) / r->o_rate;
|
||||
end = end > pd->i_count ? end - pd->i_count : 0;
|
||||
end = SPA_MIN(end, *in_len);
|
||||
chunk = SPA_MIN(end, *in_len);
|
||||
|
||||
for (; i < end; i++) {
|
||||
for (; i < chunk; i++) {
|
||||
float n = fabsf(s[i]);
|
||||
if (n > pd->max_f[channel])
|
||||
pd->max_f[channel] = n;
|
||||
|
|
|
|||
|
|
@ -818,9 +818,9 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
resample_process(&this->resample, i, src, &in_len, dst, &out_len);
|
||||
|
||||
spa_log_trace(this->log, NAME " %p: in %d/%ld %d out %d/%ld %d",
|
||||
this, in_len, size / sizeof(float), inport->offset,
|
||||
out_len, maxsize / sizeof(float), outport->offset);
|
||||
spa_log_trace(this->log, NAME " %p: in %d/%d %ld %d out %d/%d %ld %d",
|
||||
this, pin_len, in_len, size / sizeof(float), inport->offset,
|
||||
pout_len, out_len, maxsize / sizeof(float), outport->offset);
|
||||
|
||||
db->datas[i].chunk->offset = 0;
|
||||
db->datas[i].chunk->size = outport->offset + (out_len * sizeof(float));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue