## LP PHY Smooth PAPD (int winsz, int start, int end)

- Establish a phy table structure
- Calculate the size (end - start + 1)
- Allocate two tables each of 256 bytes, a source and a destination
- Set the table length to 64
- Set the table ID to 9
- Set the table offset to 0
- Set the table width to 32
- Set the table data pointer to the source buffer above
- Start a loop
win_start = end - min(end, winsz >> 1)

win_end = min(63, end + winsz >> 1)

- number to average is win_end - win_start + 1
- Zero two quantities called eps_real and eps_imag
- Loop from win_start to win_end (inclusive)
- Use the loop index to get a data word from the source table and right shift by 12
- If the result is greater than 0x7FF
- Sign extend by subtracting 0x1000

- Add the result to eps_real
- Use the loop index to get the same data word and mask with 0xFFF
- If the result is greater than 0x7FF
- Sign extend as above

- Add the result to eps_imag

- Divide eps_real and eps_imag by the number of steps in the loop
- Calculate eps_real left-shifted by 12 and bitwise ORed with (eps_imag masked with 0xFFF)
- Save the result in the destination table using "end" as the index
- Decrement end
- Repeat as long as end not equal to start

- Set the table data pointer to destination
- Set the table length to end - start + 1
- Set the table offset to 0
- Free the table space