Sign in

username:

password:



Not a member?

Search speechcoding



Search tips

Subscribe to speechcoding



speechcoding by Keywords

ACELP | ADPCM | AMBE | AMR | AMR-NB | CELP | Codebook | DTMF | G.723 | G.726 | G.729 | GSM | Interpolation | LPC | LSF | LSP | MELP | PCM | Perceptual | Pitch | PSOL | QCELP | Quantization | SMV | VAD | Vocoder


Discussion Groups

Discussion Groups | Speech Coding | Floating point C Code to fixed point conversion of iLBC

Technical discussions related to Speech Coding (all itu and other vocoders, ACELP, CELP, AMR, etc)

  

Post a new Thread

Floating point C Code to fixed point conversion of iLBC - aditya_naidu1 - Apr 21 3:38:00 2005





Hello All,

I am doing a floating point C code to fixed point conversion of iLBC
(Internet Low Bit rate Codec).Kindly help me with the following:
1) How to convert numbers such as -1.85,-10.45,-1.008 to fixed point?
2) How to convert numbers such as 1.85,10.45 etc to fixed point?
3) Is there any general rule to follow when doing these conversion?
4) How to implement cos and log in fixed point?

Pls help.

Aditya





(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

Re: Floating point C Code to fixed point conversion of iLBC - Erik Stetina - Apr 21 8:20:00 2005


aditya_naidu1 wrote: >Hello All,
>
>I am doing a floating point C code to fixed point conversion of iLBC
>(Internet Low Bit rate Codec).Kindly help me with the following:
>1) How to convert numbers such as -1.85,-10.45,-1.008 to fixed point?
>2) How to convert numbers such as 1.85,10.45 etc to fixed point?
>3) Is there any general rule to follow when doing these conversion?
>4) How to implement cos and log in fixed point?
>
>Pls help.
>
>Aditya For computing with number such as 0.21 in fixed point you have to use
some scale factor... short example: # include <stdio.h>
# include <math.h>
main()
{
// how to compute 0.21 * 500 in fixed point?

float FloatPointValue = 0.21;
int scale = 16;

// mapping
int FixedPointValue = round(FloatPointValue*(1<<scale));

// here is your fixed point algorithm
FixedPointValue = FixedPointValue * 500; // remapping
float result = FixedPointValue>>scale;

// printing result
printf("%f\n",FloatPointValue*500);
printf("%f\n",result);
}

hope it helps...





(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

Re: Floating point C Code to fixed point conversion of iLBC - Steve Holle - Apr 21 10:24:00 2005


The following is a asm snippet from a routine I use to scale and
convert a float to an integer on a 21161 SHARC :

f1 = f4 * f8,
r2 = fix f1 ;

I'd be glad to attach the entire source for this routine if you are interested. At 01:38 AM 4/21/2005, aditya_naidu1 wrote:
>Hello All,
>
>I am doing a floating point C code to fixed point conversion of iLBC
>(Internet Low Bit rate Codec).Kindly help me with the following:
>1) How to convert numbers such as -1.85,-10.45,-1.008 to fixed point?
>2) How to convert numbers such as 1.85,10.45 etc to fixed point?
>3) Is there any general rule to follow when doing these conversion?
>4) How to implement cos and log in fixed point?
>
>Pls help.
>
>Aditya
Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT 59101
sholle@shol...




(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

Re: Floating point C Code to fixed point conversion of iLBC - Phil Frisbie, Jr. - Apr 21 13:36:00 2005


aditya_naidu1 wrote:
>
> Hello All,
>
> I am doing a floating point C code to fixed point conversion of iLBC
> (Internet Low Bit rate Codec).Kindly help me with the following:
> 1) How to convert numbers such as -1.85,-10.45,-1.008 to fixed point?
> 2) How to convert numbers such as 1.85,10.45 etc to fixed point?
> 3) Is there any general rule to follow when doing these conversion?
> 4) How to implement cos and log in fixed point?

Why not use something like GSM 6.10 that is already readily available as fixed
point? It has about the same bit rate as iLBC.

Anyway... The conversion of floating point code to fixed point is not trivial,
and involves overcoming several problems:

How many bits per fixed point value do you have? 16 or 32 are most common.

What precision do you need?

What scaling do you need?

Can you modify the code to allow the same precision and scaling throughout the
codec, or do you need to scale between some modules?

I first converted some floating point code to fixed point in 1993 to speed up a
game on 80386 CPUs. I have since converted two full codecs and various other
code, so I know just how hard it can be! The last codec I converted, LPC-10e,
took in excess of 160 hours of work to get it to within 98% compliance with the
original floating point code.

If that did not scare you off then read this introduction to fixed point:
http://home.earthlink.net/~yatescr/fp.pdf

I have been working on an article for a magazine for the last year on floating
to fixed point conversion, but the time has not been available to finish it.

> Pls help.
>
> Aditya

--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com




(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

Re: Floating point C Code to fixed point conversion of iLBC - bhagawan reddy - Apr 21 19:30:00 2005


Hi Aditya ,

Here are my suggestions : Assuming that you are using 16-bit(q15 format) 1) How to convert numbers such as -1.85,-10.45,-1.008 to fixed point?

take -10.45

Of 16-bits u have
1 is sign bit, 10 is an integer and needs 4 bits to be represented, and rest 11 bits can be used for fraction.Hence your output format is q4.11

Therefor fixed point representation of -10.45 is computed

-10.45 * pow(2,11) == -21401 == 0xAC67

Similar way u can do the rest .
But when you want to add to fixed point numbers, be sure they are in same format.
2) How to convert numbers such as 1.85,10.45 etc to fixed point?

With the above explanation,

10.45*pow(2,11) == 21401 == 0x5399

3) Is there any general rule to follow when doing these conversion?

Depending on the precision you need .
You can never neglect integer bits , sometimes you can compromise on fractional bits.

4) How to implement cos and log in fixed point?

You can use Taylor's series Regards,
Bhagawan

Yahoo! India Matrimony: Find your life partneronline.





(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

Re: Floating point C Code to fixed point conversion of iLBC - prakash sebastian - Apr 21 23:41:00 2005

Numbers such as +/- 1.85 require one integer bit besides the fractional part hence such numbers can be represented in Q14 format i.e. simply scale the number by (1<<14) for a 16-bit implementation. Simillarly numbers such as 10.45 require 4 bits of integer plus the decimal part hence use Q11 ie scale the number by (1<<11).
 
There are various open source speech codecs which have the cos and log functions already implemented. You can have a look at those functions..

aditya_naidu1 <a...@pmail.ntu.edu.sg> wrote:
Hello All,

I am doing a floating point C code to fixed point conversion of iLBC
(Internet Low Bit rate Codec).Kindly help me with the following:
1) How to convert numbers such as -1.85,-10.45,-1.008 to fixed point?
2) How to convert numbers such as 1.85,10.45 etc to fixed point?
3) Is there any general rule to follow when doing these conversion?
4) How to implement cos and log in fixed point?

Pls help.

Aditya------------------------ Yahoo! Groups Sponsor --------------------~-->
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EA3HyD/3MnJAA/79vVAA/GP4qlB/TM
--------------------------------------------------------------------~-
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/speechcoding/

<*> To unsubscribe from this group, send an email to:
s...@yahoogroups.com

<*

__________________________________________________

(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

GSM 6.10 source code, Was: Floating point C Code to fixed point conversion of iLBC - Phil Frisbie, Jr. - Apr 22 12:20:00 2005


Phil Frisbie, Jr. wrote: > aditya_naidu1 wrote:
>
>>Hello All,
>>
>>I am doing a floating point C code to fixed point conversion of iLBC
>>(Internet Low Bit rate Codec).Kindly help me with the following:
>>1) How to convert numbers such as -1.85,-10.45,-1.008 to fixed point?
>>2) How to convert numbers such as 1.85,10.45 etc to fixed point?
>>3) Is there any general rule to follow when doing these conversion?
>>4) How to implement cos and log in fixed point? > Why not use something like GSM 6.10 that is already readily available as fixed
> point? It has about the same bit rate as iLBC.

Several people have contacted me directly asking about GSM 6.10 source code. You
can either get some reference code from http://kbs.cs.tu-berlin.de/~jutta/toast.html

Or I include a copy of GSM 6.10 that has been optimized in my free and open
source HawkVoiceDI library, available from my website below. --
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com




(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )