Jan Stary <h...@stare.cz> writes:

> On May 21 18:08:08, martinw...@gmail.com wrote:
>> 
>> On 5/21/24 17:00, Måns Rullgård wrote:
>> > Martin Guy <martinw...@gmail.com> writes:
>> > 
>> > diff --git a/src/spectrogram.c b/src/spectrogram.c
>> > index 3dcda69c..c13eb6c9 100644
>> > --- a/src/spectrogram.c
>> > +++ b/src/spectrogram.c
>> > @@ -867,7 +867,7 @@ static int stop(sox_effect_t *effp) /* only called, by 
>> > end(), on flow 0 */
>> >       /* X-axis */
>> >       step = axis(secs(p->cols), p->cols / (font_X * 9 / 2), &limit, 
>> > &prefix);
>> >       sprintf(text, "Time (%.1ss)", prefix);               /* Axis label */
>> > -    print_at(left + (p->cols - font_X * strlen(text)) / 2, 24, Text, 
>> > text);
>> > +    print_at(left + (p->cols - font_X * (int)strlen(text)) / 2, 24, Text, 
>> > text);
>> >       for (i = 0; i <= limit; i += step) {
>> >         int x = limit ? (double)i / limit * p->cols + .5 : 0;
>> > There must be something else/additional going on, because on my system
>> > it segfaults with or without this patch.
>> > 
>> Well, it does the trick on my Debian 32-bit x86. If you'll say what your
>> system is, to see if I can reproduce the problem on a similar compile farm
>> machine
>
> The segfault persists in OpenBSD 7.5 (amd64),
> and appears to not be related to this (see previous mail).

Try this patch:

--- a/src/spectrogram.c
+++ b/src/spectrogram.c
@@ -431,7 +431,7 @@ static int start(sox_effect_t *effp)
   actual = make_window(p, p->last_end = 0);
   lsx_debug("window_density=%g", actual / p->dft_size);
   p->step_size = (p->slack_overlap ? sqrt(actual * p->dft_size) : actual) + 
0.5;
-  p->block_steps = effp->in_signal.rate / pixels_per_sec;
+  p->block_steps = max(effp->in_signal.rate / pixels_per_sec, 1);
   p->step_size =
     p->block_steps / ceil((double)p->block_steps / p->step_size) + 0.5;
   p->block_steps = floor((double)p->block_steps / p->step_size + 0.5);


-- 
Måns Rullgård


_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to