<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1715/">https://reviewboard.asterisk.org/r/1715/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Totally agree with kpfleming on this one.</pre>
<br />
<p>- Joshua</p>
<br />
<p>On February 6th, 2012, 4:32 p.m., Mark Michelson wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Mark Michelson.</div>
<p style="color: grey;"><i>Updated Feb. 6, 2012, 4:32 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The linked issue mentions that Asterisk 1.8 will choose to translate from slin16 to slin8 via the G.722 codec rather than use codec_resample in order to translate directly between the formats. The reporter contends that the quality of the translation should be taken into effect in addition to the cost, suggesting that single-step translations should be favored over multi-step translations.
I did quite a bit of research, and I found that sometimes, Asterisk actually would translate from slin16 to slin8 directly, but most of the time, Asterisk would use G.722 as a middle step. And if I issued a "core show translation recalc 1000" so that translation costs were based off 1000 seconds of audio instead of 1, the cost clearly converged to the point that G.722 was the better path. Typically, the path from slin16->G.722->slin8 would have a total cost of around 1700, but the path directly from slin16->slin18 would have a cost of around 6500.
I also tested out Asterisk 10 to see how it chooses translation paths. Interestingly, Asterisk 10 does not use the combined computational cost to choose translation paths. Rather, it uses a separate cost scale based on the sampling rate change and the quality of the translation. So in this particular situation, since the slin16->g.722 is a lossy translation, but the slin16->slin8 is deemed a lossless translation, the slin16->slin8 translation will always be used.
SO, on to the actual change contained here. It's a two line change that simply takes computational cost out of the equation when creating multistep translations. This essentially means that a multistep translation will only be used if there is no direct translation between the source and destination formats.
I will concede that there may be a better way of addressing this issue, so if you have suggestions, please don't hesitate to let me know.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Started Asterisk, and recalculated translation matrix several times. After each, I issued "core show translation paths slin16" and ensured that the path chosen was always from slin16 directly to slin8 and never through g.722.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-16821">ASTERISK-16821</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/main/translate.c <span style="color: grey">(354120)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1715/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>