opus_decode() produces 16-bit signed linear PCM, and opus_decode_float() produces 32-bit floating point PCM that is useful when you want a higher bit depth. If you need 8-bit linear PCM then a simple solution would be to use only the top 8 bits of each 16-bit sample from opus_decode(). Note that the WAV format uses unsigned rather than signed integers for 8-bit linear PCM. (It uses signed for larger sample sizes and AIFF uses signed for all sizes.) So if you are writing 8-bit linear PCM to WAV then you would need something like (((unsigned short)sample ^ 0x8000) >> 8) to convert from signed to unsigned and get the top 8 bits of each sample. You will achieve better quality, however, if you apply dither. opusdec applies dither by default if the output is not floating point, although it does not support 8-bit output. - Mark
Hello Mark, Thanks. Let me try the proposed configuration first to make sure that linear 8-bit PCM is retrieved. Regards Amit On Sat, Jan 9, 2016 at 12:28 PM, Mark Harris <mark.hsj at gmail.com> wrote:> opus_decode() produces 16-bit signed linear PCM, and > opus_decode_float() produces 32-bit floating point PCM that is useful > when you want a higher bit depth. > > If you need 8-bit linear PCM then a simple solution would be to use > only the top 8 bits of each 16-bit sample from opus_decode(). Note > that the WAV format uses unsigned rather than signed integers for > 8-bit linear PCM. (It uses signed for larger sample sizes and AIFF > uses signed for all sizes.) So if you are writing 8-bit linear PCM to > WAV then you would need something like (((unsigned short)sample ^ > 0x8000) >> 8) to convert from signed to unsigned and get the top 8 > bits of each sample. > > You will achieve better quality, however, if you apply dither. > opusdec applies dither by default if the output is not floating point, > although it does not support 8-bit output. > > - Mark > _______________________________________________ > opus mailing list > opus at xiph.org > http://lists.xiph.org/mailman/listinfo/opus >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/opus/attachments/20160109/e26cd913/attachment.htm
Hello Mark, The resulting 8 bit file has a lot of squelching noise compared to the 16 bit output from OPUS decoder. During encode I am using popi16fmtBuffer[ui32Loop] = (opus_int16)pcRdBuf[ui32Loop]; And during decode since the data is in the lower 8 bit I use pc8bitSamples[ui32Loop] = ((unsigned short)pcop16OutBuf[ui32Loop] ^ 0x80); Regards Amit On Sat, Jan 9, 2016 at 2:39 PM, Amit Ashara <ashara.amit at gmail.com> wrote:> Hello Mark, > > Thanks. Let me try the proposed configuration first to make sure that > linear 8-bit PCM is retrieved. > > Regards > Amit > > On Sat, Jan 9, 2016 at 12:28 PM, Mark Harris <mark.hsj at gmail.com> wrote: > >> opus_decode() produces 16-bit signed linear PCM, and >> opus_decode_float() produces 32-bit floating point PCM that is useful >> when you want a higher bit depth. >> >> If you need 8-bit linear PCM then a simple solution would be to use >> only the top 8 bits of each 16-bit sample from opus_decode(). Note >> that the WAV format uses unsigned rather than signed integers for >> 8-bit linear PCM. (It uses signed for larger sample sizes and AIFF >> uses signed for all sizes.) So if you are writing 8-bit linear PCM to >> WAV then you would need something like (((unsigned short)sample ^ >> 0x8000) >> 8) to convert from signed to unsigned and get the top 8 >> bits of each sample. >> >> You will achieve better quality, however, if you apply dither. >> opusdec applies dither by default if the output is not floating point, >> although it does not support 8-bit output. >> >> - Mark >> _______________________________________________ >> opus mailing list >> opus at xiph.org >> http://lists.xiph.org/mailman/listinfo/opus >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/opus/attachments/20160111/238b296f/attachment.htm