• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: using integer audio data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using integer audio data


  • Subject: Re: using integer audio data
  • From: "Timothy J. Wood" <email@hidden>
  • Date: Tue, 21 Aug 2001 18:23:38 -0700

On Tuesday, August 21, 2001, at 02:56 PM, Jeff Moore wrote:
You can't using the HAL API. It only allows for 32 bit float data when doing
IO with linear PCM sample formats. You don't have any choice but to convert.

OK, well it's good to know that I'm not missing something obvious then :)


Int/float conversions suck on PPC

I don't know about that. They suck about as much as they do on any
processor. Of course with Altivec, you can do it 4 samples at a time with a
single instruction and that definitely does not suck.

They are much worse then the other common processor in the world (x86, of course).

The typical depression version PPC version of this can be seen by building something like:

/*
cc -O2 -S int-to-float.c
*/

float int_to_float(int x)
{
return x;
}


This results in something along these lines:

LC0:
.double 0r4.50360177485414400000e15
.text
.align 2
.globl _int_to_float
_int_to_float:
mflr r0
bcl 20,31,L1$pb
L1$pb:
mflr r12
mtlr r0
xoris r3,r3,0x8000
stw r3,-4(r1)
lis r0,0x4330
addis r11,r12,ha16(LC0-L1$pb)
stw r0,-8(r1)
la r11,lo16(LC0-L1$pb)(r11)
lfd f1,-8(r1)
lfd f0,0(r11)
fsub f1,f1,f0
frsp f1,f1
blr


Note that the int to float here does FOUR memory operations. One of these is hoisted if you do a loop. Two could be hoisted, but GCC isn't smart enough on the PPC to do this. Thus, you are left with three memory operations. This doesn't even count the load of the initial value you are converting and the store of the resulting value.

Terrible! :)

Altivec actually (gasp) has an instruction to convert between integer and floating point formats. Sadly, Apple hasn't sold enough G4 machines to replace all the G3s in the field.

PPC really needs an instruction that converts an integer to a floating point value in an integer register. It isn't like I'm asking the IU to do FPU ops, just to do a conversion. This would allow you to load the value, convert it and then if you actually wanted to use it, you could store it out and then load it into a FP register.

OK, enough bellyaching :)

-tim


  • Follow-Ups:
    • Re: using integer audio data
      • From: Raphaël Dingé <email@hidden>
References: 
 >Re: using integer audio data (From: Jeff Moore <email@hidden>)

  • Prev by Date: Re: using integer audio data
  • Next by Date: Buffer redundancy?
  • Previous by thread: Re: using integer audio data
  • Next by thread: Re: using integer audio data
  • Index(es):
    • Date
    • Thread