[Home]

Summary:ASTERISK-28311: dsp: ast_dsp_silence_noise_with_energy wrong judgment of frame format
Reporter:周家建 (zhou_jiajian)Labels:
Date Opened:2019-02-27 22:25:50.000-0600Date Closed:2020-09-25 08:22:23
Priority:MinorRegression?
Status:Closed/CompleteComponents:Core/General
Versions:16.2.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:
Description:In ast_dsp_silence_noise_with_energy function,failure to make a correct judgement on the return value of ast_format_cmp. This problem can lead to the energy of linear data does not match the energy of actual data.
Comments:By: Asterisk Team (asteriskteam) 2019-02-27 22:25:51.121-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Joshua C. Colp (jcolp) 2019-02-28 05:12:19.837-0600

You're going to need to be more specific. What exactly are you referring to? The function itself only supports signed linear, ulaw and alaw. Is one of those incorrect?

By: 周家建 (zhou_jiajian) 2019-03-09 00:14:27.471-0600

I'm sorry I didn't explain the problem.
in the ast_dsp_silence_noise_with_energy, there is a problem with the judgment of frame format.

"if (ast_format_cmp(f->subclass.format, ast_format_ulaw)" should be "if (ast_format_cmp(f->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL)"

"if (ast_format_cmp(f->subclass.format, ast_format_ulaw)" should be "if (ast_format_cmp(f->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) "

The original way will go into the wrong conversion format.

diff --git a/main/dsp.c b/main/dsp.c
index 1a3ebea..6d74b65 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -1433,12 +1433,12 @@ static int ast_dsp_silence_noise_with_energy(struct ast_dsp *dsp, struct ast_fra
} else {
odata = f->data.ptr;
len = f->datalen;
- if (ast_format_cmp(f->subclass.format, ast_format_ulaw)) {
+ if (ast_format_cmp(f->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
s = ast_alloca(len * 2);
for (x = 0; x < len; x++) {
s[x] = AST_MULAW(odata[x]);
}
- } else if (ast_format_cmp(f->subclass.format, ast_format_alaw)) {
+ } else if (ast_format_cmp(f->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
s = ast_alloca(len * 2);
for (x = 0; x < len; x++) {
s[x] = AST_ALAW(odata[x]);

By: Benjamin Keith Ford (bford) 2019-03-12 14:37:33.408-0500

I think you are correct here, since AST_FORMAT_CMP_EQUAL evaluates to 0, so this would either need a "!", or the fix that you have suggested. Would you like to submit a patch on Gerrit [1] for this?

[1]: https://gerrit.asterisk.org

By: 周家建 (zhou_jiajian) 2019-03-14 23:43:25.665-0500

yes, i will submit this patch.

By: Friendly Automation (friendly-automation) 2020-09-25 08:22:25.632-0500

Change 14936 merged by Friendly Automation:
dsp.c: Update calls to ast_format_cmp to check result properly

[https://gerrit.asterisk.org/c/asterisk/+/14936|https://gerrit.asterisk.org/c/asterisk/+/14936]

By: Friendly Automation (friendly-automation) 2020-09-25 08:25:33.706-0500

Change 14987 merged by Friendly Automation:
dsp.c: Update calls to ast_format_cmp to check result properly

[https://gerrit.asterisk.org/c/asterisk/+/14987|https://gerrit.asterisk.org/c/asterisk/+/14987]

By: Friendly Automation (friendly-automation) 2020-09-25 08:37:24.894-0500

Change 14990 merged by George Joseph:
dsp.c: Update calls to ast_format_cmp to check result properly

[https://gerrit.asterisk.org/c/asterisk/+/14990|https://gerrit.asterisk.org/c/asterisk/+/14990]

By: Friendly Automation (friendly-automation) 2020-09-25 08:37:39.431-0500

Change 14988 merged by George Joseph:
dsp.c: Update calls to ast_format_cmp to check result properly

[https://gerrit.asterisk.org/c/asterisk/+/14988|https://gerrit.asterisk.org/c/asterisk/+/14988]

By: Friendly Automation (friendly-automation) 2020-09-25 08:37:49.546-0500

Change 14989 merged by George Joseph:
dsp.c: Update calls to ast_format_cmp to check result properly

[https://gerrit.asterisk.org/c/asterisk/+/14989|https://gerrit.asterisk.org/c/asterisk/+/14989]