[Speex-dev] using unsigned short instead of short for input frame

Mashal al-shboul shboul8989 at yahoo.com
Fri Mar 9 08:36:05 PST 2012


Thanks for your appreciated help.
i found casting fromunsigned short to short gives different value: unsigned short FFFF=65535 where short FFFF= -1.
however, can i configure speex codec (specifically speex_encode_int function) to take input of type unsigned short instead of short so that i avoid casting errors ?

Regards,
Mashal



________________________________
 From: Yanick Bourbeau <ybourbeau at mrgtech.ca>
To: Mashal al-shboul <shboul8989 at yahoo.com> 
Sent: Friday, March 9, 2012 4:29 PM
Subject: Re: [Speex-dev] using unsigned short instead of short for input frame
 

uint16_t is usually a typedef of an unsigned short or int depending of the platform. It is supposed to work. About unsigned short to short conversion it is normal since unsigned short starts at 0 and short starts at -((2^16)/2)-1 [-32767]. If you really want to keep the same numeric value you could cast the short to unsigned int (32bytes) and add 32767 to the value. 

On 12-03-09 02:59 AM, Mashal al-shboul wrote: 
Hi Speex Experts,Thanks for this great mailing list.
>
>
>     i want to compress a frame of(uint16_t) audio samples, i found that speex codec assumes input frame of type short. fortunately,both data types are of  2-bytes , so my questions :
>- can i cast data types for input to speex?, if so,can i cast uint16_t to unsigned short and still be accepted by speex ? ,
>because i found converting from uint16_t to short does completely change the values of the samples(unsigned to signed !).
>
>
>Any help or suggestion is appreciated. Thanks in advance.
>
>
>Regards,
>Mash'al
>
>
>
>
>_______________________________________________
Speex-dev mailing list Speex-dev at xiph.org http://lists.xiph.org/mailman/listinfo/speex-dev 
e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20120309/fb4e5810/attachment.htm 


More information about the Speex-dev mailing list