[Speex-dev] About "Convert 8->16 bits"

yaseminyilmaz yaseminyilmaz at aytor.com
Fri Dec 15 08:46:01 PST 2006


 

Hi everybody,

 

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've done the convertion as
following.

 

for(int i=0; i<160; ++i)

{

            input_frame[i] = (short)( (data[2*i] << 8) | data[2*i+1]);

      }

 

When my codec application didn'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't understand why the convertion is done in this
way:

 

      for(i=frame_size*channels-1;i>=0;i--)

      {

         s[i]=(in[i]<<8)^0x8000;

      }

 

(in my application, channels is 1 and frame_size=160)

 

I can understand why shift left 8, but can't why we should do XOR operation
with 1000 0000 0000 0000. Should I do the convertion operation so and why?
Please can you clarify? Thanks a lot for your helps.

 

Sincerely

Yasemin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20061215/2e728872/attachment.html


More information about the Speex-dev mailing list