Converting fixed point numbers

View: New views
2 Messages — Rating Filter:   Alert me  

Converting fixed point numbers

by Reiner-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

madplay uses the following in audio_linear_round

  /* quantize and scale */
  return sample >> (MAD_F_FRACBITS + 1 - bits);

if bits is 16 (unsigned short e,g) we will shift 13 bits, whats about
the 3 MSB bits ???

With this I think only the first digit of the whole part is taken, what
is with the sign and the other 2 digits from the whole part, are they
never used?

Thanks

Reiner


Re: Converting fixed point numbers

by Rob Leslie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Jul 12, 2008, at 10:56 AM, Reiner wrote:

> madplay uses the following in audio_linear_round
>
> /* quantize and scale */
> return sample >> (MAD_F_FRACBITS + 1 - bits);
>
> if bits is 16 (unsigned short e,g) we will shift 13 bits, whats  
> about the 3 MSB bits ???
>
> With this I think only the first digit of the whole part is taken,  
> what is with the sign and the other 2 digits from the whole part,  
> are they never used?

The whole part is used to represent samples that are above full scale  
[-1.0, 1.0) but madplay clips these prior to scaling, so at this point  
the whole part just contains copies of the sign bit.

--
Rob Leslie
rob@...