[asterisk-bugs] [JIRA] (ASTERISK-28311) ast_dsp_silence_noise_with_energy wrong judgment of frame format

周家建 (JIRA) noreply at issues.asterisk.org
Sat Mar 9 00:19:47 CST 2019


    [ https://issues.asterisk.org/jira/browse/ASTERISK-28311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=246511#comment-246511 ] 

周家建 edited comment on ASTERISK-28311 at 3/9/19 12:19 AM:
---------------------------------------------------------

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]);


was (Author: zhou_jiajian):
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.

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]);

> ast_dsp_silence_noise_with_energy wrong judgment of frame format
> ----------------------------------------------------------------
>
>                 Key: ASTERISK-28311
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-28311
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Core/General
>    Affects Versions: 16.2.0
>            Reporter: 周家建
>            Assignee: Unassigned
>            Severity: Minor
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list