SV: [Speex-dev] About "Convert 8->16 bits"
njt at home.se
Fri Dec 15 09:01:57 PST 2006
Id say this is out of scope for this mailing list. Any how, you cant
just shift a signed number by 8 (multiplying with 256) without handling
PCM 16-bit samples are stored as signed values.
Try something simpler which works first and then optimize your code
unsigned char inSamp;
short s1, outSamp;
s1 = (short) inSamp;
s1 -= 128;
s1 *= 256;
outSamp = s1;
Its probably possible to reduce the complexity of this using bitshifts,
unless you know what you are doing and are in a lot of need for speed I
dont see the reason.
Från: speex-dev-bounces at xiph.org [mailto:speex-dev-bounces at xiph.org] För
Skickat: den 15 december 2006 17:46
Till: speex-dev at xiph.org
Ämne: [Speex-dev] About "Convert 8->16 bits"
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. Ive done the convertion
for(int i=0; i<160; ++i)
input_frame[i] = (short)( (data[2*i] << 8) | data[2*i+1]);
When my codec application didnt 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 cant understand why the convertion
is done in this way:
(in my application, channels is 1 and frame_size=160)
I can understand why shift left 8, but cant 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Speex-dev