<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 />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/1715/diff/1/?file=23891#file23891line520" style="color: black; font-weight: bold; text-decoration: underline;">/branches/1.8/main/translate.c</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static void rebuild_matrix(int samples)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">520</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="cm">                                         * 2. if x->y->z costs less and the sample rate conversion is no less optimal.</span></pre></td>
<th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">520</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="cm">                                         * 2. if x->y->z costs less and the sample rate conversion is no less optimal.</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This comment line goes with the code you have removed.</pre>
</div>
<br />
<p>- rmudgett</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>