<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="cid:filelist.xml@01C72073.1C2A4A90">
<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:DontDisplayPageBoundaries/>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:HyphenationZone>21</w:HyphenationZone>
  <w:EnvelopeVis/>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;
        mso-font-charset:0;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:1627421319 -2147483648 8 0 66047 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0cm;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.0pt;
        font-family:Arial;
        mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;
        text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;
        text-underline:single;}
span.E-postmall17
        {mso-style-type:personal;
        mso-style-noshow:yes;
        font-family:Arial;
        mso-ascii-font-family:Arial;
        mso-hansi-font-family:Arial;
        mso-bidi-font-family:Arial;
        color:windowtext;}
span.E-postmall18
        {mso-style-type:personal-reply;
        mso-style-noshow:yes;
        mso-ansi-font-size:10.0pt;
        mso-bidi-font-size:10.0pt;
        font-family:Arial;
        mso-ascii-font-family:Arial;
        mso-hansi-font-family:Arial;
        mso-bidi-font-family:Arial;
        color:navy;}
span.SpellE
        {mso-style-name:"";
        mso-spl-e:yes;}
span.GramE
        {mso-style-name:"";
        mso-gram-e:yes;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;
        mso-header-margin:35.4pt;
        mso-footer-margin:35.4pt;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */ 
 table.MsoNormalTable
        {mso-style-name:"Normal tabell";
        mso-tstyle-rowband-size:0;
        mso-tstyle-colband-size:0;
        mso-style-noshow:yes;
        mso-style-parent:"";
        mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
        mso-para-margin:0cm;
        mso-para-margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.0pt;
        font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<body lang=SV link=blue vlink=purple style='tab-interval:65.2pt'>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>I&#8217;d say this
is out of scope for this mailing list. Any how, you can&#8217;t just shift a
signed number by 8 (multiplying with 256) without handling the <span
class=SpellE>signedness</span>-bit.<o:p></o:p></span></font></p>

<p class=MsoNormal><span class=SpellE><font size=2 color=navy face=Arial><span
lang=EN-GB style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>PCM</span></font></span><font
color=navy><span lang=EN-GB style='color:navy;mso-ansi-language:EN-GB'> 16-bit
samples are stored as signed values.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>Try something
simpler which works first and then optimize your code afterwards.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><span class=GramE><font size=2 color=navy face=Arial><span
lang=EN-GB style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>unsigned</span></font></span><font
color=navy><span lang=EN-GB style='color:navy;mso-ansi-language:EN-GB'> char <span
class=SpellE>inSamp</span>;<o:p></o:p></span></font></p>

<p class=MsoNormal><span class=GramE><font size=2 color=navy face=Arial><span
lang=EN-GB style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>short</span></font></span><font
color=navy><span lang=EN-GB style='color:navy;mso-ansi-language:EN-GB'> s1, <span
class=SpellE>outSamp</span>;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>s1 = (short) <span
class=SpellE>inSamp</span>;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>s1 -= 128;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>s1 *= 256;<o:p></o:p></span></font></p>

<p class=MsoNormal><span class=SpellE><span class=GramE><font size=2
color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;color:navy;
mso-ansi-language:EN-GB'>outSamp</span></font></span></span><font color=navy><span
lang=EN-GB style='color:navy;mso-ansi-language:EN-GB'> = s1;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>It&#8217;s probably
possible to reduce the complexity of this using <span class=SpellE>bitshifts</span>,
unless you know what you are doing and are in a lot of need for speed I don&#8217;t
see the reason.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>//JT<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'>//JT<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;color:navy;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><span class=GramE><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>----<span
class=SpellE>-Ursprungligt</span> meddelande-----<br>
<b><span style='font-weight:bold'>Från:</span></b> speex-dev-bounces@xiph.org</span></font></span><font
face=Tahoma><span style='font-family:Tahoma'> [mailto:speex-dev-bounces@xiph.<span
class=GramE>org]</span> <b><span style='font-weight:bold'>För </span></b>yaseminyilmaz<br>
<b><span style='font-weight:bold'>Skickat:</span></b> den 15 december 2006
17:46<br>
<b><span style='font-weight:bold'>Till:</span></b> speex-dev@xiph.org<br>
<b><span style='font-weight:bold'>Ämne:</span></b> [Speex-dev] About
&quot;Convert 8-&gt;16 bits&quot;</span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'>Hi everybody,<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'>I have been using
speex-1.2beta1 and my input data is 8-bit unsigned so I know that I should
convert from 8 to 16 bits. I&#8217;ve done the convertion as following.<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt;text-indent:35.4pt;text-autospace:
none'><font size=2 face="Courier New"><span lang=TR style='font-size:10.0pt;
font-family:"Courier New";mso-ansi-language:TR'>for(int i=0; i&lt;160; ++i)<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt;text-indent:35.4pt;text-autospace:
none'><font size=2 face="Courier New"><span lang=TR style='font-size:10.0pt;
font-family:"Courier New";mso-ansi-language:TR'>{<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt;text-autospace:none'><font size=2
face="Courier New"><span lang=TR style='font-size:10.0pt;font-family:"Courier New";
mso-ansi-language:TR'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
input_frame[i] = (short)( (data[2*i] &lt;&lt; 8) | data[2*i+1]);<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face="Courier New"><span
lang=TR style='font-size:10.0pt;font-family:"Courier New";mso-ansi-language:
TR'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'>When my codec application
didn&#8217;t work right, I think that the reason is an error at this
convertion. For this aim, I looked at read_samples function in speexenc project
and I can&#8217;t understand why the convertion is done in this way:<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face="Courier New"><span
lang=TR style='font-size:10.0pt;font-family:"Courier New";mso-ansi-language:
TR'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i=frame_size*channels-1;i&gt;=0;i--)<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face="Courier New"><span
lang=TR style='font-size:10.0pt;font-family:"Courier New";mso-ansi-language:
TR'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face="Courier New"><span
lang=TR style='font-size:10.0pt;font-family:"Courier New";mso-ansi-language:
TR'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
s[i]=(in[i]&lt;&lt;8)^0x8000;<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face="Courier New"><span
lang=TR style='font-size:10.0pt;font-family:"Courier New";mso-ansi-language:
TR'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face="Courier New"><span
lang=TR style='font-size:10.0pt;font-family:"Courier New";mso-ansi-language:
TR'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'>(in my application,
channels is 1 and frame_size=160)<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=TR style='font-size:10.0pt;mso-ansi-language:TR'>I can understand why
shift left 8, but can&#8217;t why we should do XOR operation with 1000 0000
0000 0000. Should I do the convertion operation so and why? Please can you </span></font><span
lang=EN-US style='mso-ansi-language:EN-US'>clarify? Thanks a lot for your
helps.<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=EN-US style='font-size:10.0pt;mso-ansi-language:EN-US'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=EN-US style='font-size:10.0pt;mso-ansi-language:EN-US'>Sincerely<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:65.2pt'><font size=2 face=Arial><span
lang=EN-US style='font-size:10.0pt;mso-ansi-language:EN-US'>Yasemin</span></font><span
lang=TR style='mso-ansi-language:TR'><o:p></o:p></span></p>

</div>

</body>

</html>