0

I want to use audio codec (Speex) for compression; the codec takes audio samples of type short (2-bytes signed) as input, range:-2^15 to2^15 -1.

My problem is that I have samples of type unsigned short(2-bytes unsigned), range: 0 to 2^16 -1. So, what should I do in order to apply speex on my unsigned samples?

There is a proposed solution to subtract 2^15-1 from each unsigned short to get it as signed short, my question: is this method safe in keeping the samples meaningful for speex's processing algorithms?

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114

1 Answers1

0

To convert an unsigned short to signed, you need to subtract 2^15 or add 2^15-1 and store the result in an int.

sergio91pt
  • 1,459
  • 18
  • 21