[Asterisk-code-review] translate: Transcode siren14, speex32, silk24, and silk12 vi... (asterisk[15])

Jenkins2 asteriskteam at digium.com
Thu Nov 30 10:06:26 CST 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7372 )

Change subject: translate: Transcode siren14, speex32, silk24, and silk12 via slin16.
......................................................................

translate: Transcode siren14, speex32, silk24, and silk12 via slin16.

When a format has no pre-recorded sound files, Asterisk has to transcode between
formats. For this, Asterisk has a fixed translation table. If the pre-recorded
sound files are not available in the same sample rate, Asterisk has not only to
transcode but also to resample.

Asterisk has pre-recorded files for SLN (8000 kHz) and SLN16 (16000 kHz).
However before this change, Asterisk did not take the sample rate into account,
because the translation paths to SLN and SLN16 got the same score/weight in the
table. Consequently, you might have got narrow-band audio with siren14, speex32,
silk24, and silk12 although those are (ultra) wide-band audio codecs.

With this change, the distance in sample-rates is taken into account. Now on the
Command-Line interface (CLI) 'core show channels', you should see:
(slin at 16000)->(slin at 32000)->(speex at 32000).

ASTERISK-23735
Reported by: Richard Kenner

Change-Id: I9448295c1978be26f8633b6066395e7bbbe2e213
---
M main/translate.c
1 file changed, 15 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/main/translate.c b/main/translate.c
index f2aa588..92c0cb9 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -32,6 +32,7 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <math.h>
+#include <stdlib.h>
 
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
@@ -1390,6 +1391,20 @@
 				ao2_replace(bestdst, dst);
 				besttablecost = matrix_get(x, y)->table_cost;
 				beststeps = matrix_get(x, y)->multistep;
+			} else if (matrix_get(x, y)->table_cost == besttablecost
+					&& matrix_get(x, y)->multistep == beststeps) {
+				int gap_selected = abs(ast_format_get_sample_rate(best)
+					- ast_format_get_sample_rate(bestdst));
+				int gap_current = abs(ast_format_get_sample_rate(src)
+					- ast_format_get_sample_rate(dst));
+
+				if (gap_current < gap_selected) {
+					/* better than what we have so far */
+					ao2_replace(best, src);
+					ao2_replace(bestdst, dst);
+					besttablecost = matrix_get(x, y)->table_cost;
+					beststeps = matrix_get(x, y)->multistep;
+				}
 			}
 		}
 	}

-- 
To view, visit https://gerrit.asterisk.org/7372
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I9448295c1978be26f8633b6066395e7bbbe2e213
Gerrit-Change-Number: 7372
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171130/b8f44019/attachment.html>


More information about the asterisk-code-review mailing list