aboutsummaryrefslogtreecommitdiffstats
path: root/frame.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-28 21:49:27 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-28 21:49:27 +0000
commit762f16995626eff862c41dcc307ddf1f8779e359 (patch)
tree93888bb17ef9068a1feb3c40b552a4d316472f3a /frame.c
parentdc1aa1ffdc495cfff0c483ac6056bc8b203ee3ff (diff)
add API call to properly sum two frames of SLINEAR data
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6883 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'frame.c')
-rwxr-xr-xframe.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/frame.c b/frame.c
index 39bed2e01..5952b1d74 100755
--- a/frame.c
+++ b/frame.c
@@ -1271,3 +1271,25 @@ int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
return 0;
}
+
+int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2)
+{
+ int count;
+ short *data1, *data2;
+
+ if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass != AST_FORMAT_SLINEAR))
+ return -1;
+
+ if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass != AST_FORMAT_SLINEAR))
+ return -1;
+
+ if (f1->samples != f2->samples)
+ return -1;
+
+ for (count = 0, data1 = f1->data, data2 = f2->data;
+ count < f1->samples;
+ count++, data1++, data2++)
+ ast_slinear_saturated_add(data1, *data2);
+
+ return 0;
+}