<div dir="ltr"><div><div><div>Hello Benjamin,<br><br></div>The original WAV file I have is linear 8-bit PCM. I want to ensure that original linear formats are kept as is.<br><br></div><div>Later I will add support for ulaw.<br></div><div><br></div>Regards<br></div>Amit<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 8, 2016 at 5:34 PM, Benjamin Schwartz <span dir="ltr">&lt;<a href="mailto:benjamin.m.schwartz@gmail.com" target="_blank">benjamin.m.schwartz@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Do you really need linear 8-bit PCM or do you want ulaw?  Linear 8-bit is ... pretty rare.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Jan 7, 2016 at 8:11 PM, Amit Ashara <span dir="ltr">&lt;<a href="mailto:ashara.amit@gmail.com" target="_blank">ashara.amit@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div>Hello Ralph,<br><br></div><div>I was finally able to get it to work for both 8 and 16 bit PCM data. However the output of the decoder is always 16 bit PCM and never the original 8 bit making the wav file decoded 2x times the original file.<br><br></div><div>This is a restriction for some embedded system. Any idea how to work around or fix the issue?<br><br></div><div>I did try reading out the 8-bit data from the 16 bit output but it does not seem that simple (based on <a href="http://stackoverflow.com" target="_blank">stackoverflow.com</a>) and I am still searching on an easier mechanism.<br></div><div><br></div>Regards<span><font color="#888888"><br></font></span></div><span><font color="#888888">Amit<br></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 7, 2016 at 12:41 PM, Amit Ashara <span dir="ltr">&lt;<a href="mailto:ashara.amit@gmail.com" target="_blank">ashara.amit@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hello Ralph,<span><br><br>&gt; Likewise opus_encode() takes 16 bit samples, so you need to extend each<br>&gt; sample from an 8 bit source before encoding.<br><br></span></div><div>Two questions<br></div><div>1. In opusenc.c which API does the extending the 8-bit to 16-bit?<br></div><div>2. If that is the case then how will 24 bit PCM sample work?<br></div><div><br></div>Regards<span><font color="#888888"><br></font></span></div><span><font color="#888888">Amit<br></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 7, 2016 at 12:21 PM, Ralph Giles <span dir="ltr">&lt;<a href="mailto:giles@thaumas.net" target="_blank">giles@thaumas.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 07/01/16 10:04 AM, Amit Ashara wrote:<br>
<br>
&gt; opus_decoder_ctl(sOpusDec, OPUS_SET_LSB_DEPTH(ui32BitsPerSample));<br>
<br>
OPUS_SET_LSB_DEPTH only affects the encoder. If you check the return<br>
value here you should get OPUS_UNIMPLEMENTED.<br>
<span><br>
&gt; output_samples = opus_decode(sOpusDec, (const unsigned char<br>
&gt; *)&amp;pcRdBuf[0], len, opi16_out, (ui32SizeOfWrBuf/ui8ScaleFactor), 0);<br>
<br>
</span>I suspect the issue is dividing by ui8ScaleFactor = 1 here.<br>
OPUS_SET_LSB_DEPTH works as a precision hint to the encoder about where<br>
to set the noise floor, but opus_decode still returns 16 bit samples. It<br>
always returns 16 bit samples, regardless of whether the original input<br>
as 8 bit, 16 bit or 24 bit precision (from opus_encode_float).<br>
<br>
To actually output 8-bit wav, you have to keep track of this out-of-band<br>
and truncate each sample before writing it out.<br>
<br>
Likewise opus_encode() takes 16 bit samples, so you need to extend each<br>
sample from an 8 bit source before encoding.<br>
<br>
HTH,<br>
 -r<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br></div></div>_______________________________________________<br>
opus mailing list<br>
<a href="mailto:opus@xiph.org" target="_blank">opus@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/opus" rel="noreferrer" target="_blank">http://lists.xiph.org/mailman/listinfo/opus</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>