sox-devel@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
From: Pander <pander@users.sourceforge.net>
To: sox-devel@lists.sourceforge.net
Subject: Re: Review patch for average power spectrum
Date: Mon, 22 Dec 2014 23:59:28 +0100	[thread overview]
Message-ID: <5498A250.5080301@users.sourceforge.net> (raw)
In-Reply-To: <20141222221450.GA28373@dcvr.yhbt.net>

[-- Attachment #1: Type: text/plain, Size: 2107 bytes --]

On 12/22/2014 11:14 PM, Eric Wong wrote:
> Pander <pander@users.sourceforge.net> wrote:
>> Please review the attached patch for outputting the average power spectrum.
> 
> I am not knowledgable in the math behind this, but I noticed one
> memory management error:
> 
>> @@ -134,6 +138,15 @@ static int sox_stat_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_samp
>>    priv_t * stat = (priv_t *) effp->priv;
>>    int done, x, len = min(*isamp, *osamp);
>>    short count = 0;
>> +  float *re_average;
> 
> re_average needs to be initialized for the "stat->fft_average != 1" case
> 
>   float *re_average = NULL;

Thanks, that will also remove a warning.

Please see the attachement for the incremental patch.

The first patch also included some of the changes coming in with the
promoted git pull in http://sox.sourceforge.net/ but git can split them
in the patch for the maintainer.

> 
>> +  if (stat->fft_average == 1) {
>> +      samples = (stat->fft_size / 2);
>> +      ffa = effp->in_signal.rate / samples;
>> +      re_average = lsx_malloc(sizeof(float) * (int)samples);
>> +  }
> 
> ...otherwise, free may be called on an uninitialized value:
> 
>> +  if (re_average) {
>> +    free(re_average);
>> +  }
>>    *isamp = *osamp = len;
>>    /* Process all samples */
> 
> There's also a bunch of unrelated whitespace eliminations
> in the manpage which should probably be a separate commit
> (but I'm not a sox maintainer, just another user + occasional patcher).
> 
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> SoX-devel mailing list
> SoX-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-devel
> 


[-- Attachment #2: 0001-Im-proved-memory-management.patch --]
[-- Type: text/x-patch, Size: 700 bytes --]

>From 94c0f9125b77f0f9a678c9766330e7e55b5ec546 Mon Sep 17 00:00:00 2001
From: Pander <pander@users.sourceforge.net>
Date: Mon, 22 Dec 2014 23:56:37 +0100
Subject: [PATCH] Im proved memory management

---
 src/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/stat.c b/src/stat.c
index 63d1741..0ce8415 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -138,7 +138,7 @@ static int sox_stat_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_samp
   priv_t * stat = (priv_t *) effp->priv;
   int done, x, len = min(*isamp, *osamp);
   short count = 0;
-  float *re_average;
+  float *re_average = NULL;
   unsigned samples = 0;
   float ffa = 0.0;
   unsigned i;
-- 
2.1.0


[-- Attachment #3: Type: text/plain, Size: 440 bytes --]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

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

  reply	other threads:[~2014-12-22 23:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22 21:50 Review patch for average power spectrum Pander
2014-12-22 22:14 ` Eric Wong
2014-12-22 22:59   ` Pander [this message]
2014-12-22 23:02   ` Cedric Roux
2014-12-23 19:05     ` Pander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.sourceforge.net/lists/listinfo/sox-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5498A250.5080301@users.sourceforge.net \
    --to=sox-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).