2

Starting from this question I was made to understand how to deinterleave the left and right channel of a 16 bit PCM data.

My question now is, how will a 8 bit PCM be deinterleaved and "stretched" into a 16 bit value

Community
  • 1
  • 1
MOHW
  • 737
  • 1
  • 11
  • 23
  • Given interleaving of 8 bits left channel, 8 bits right channel repeated, what do you need to know about uninterleaving? If you want to "stretch" it, a crude way is to multiply by 256 (i.e. treat the byte as if it were the ms/high byte in 16 bit data with a "0" ls/low byte.) If you want to attempt some kind of smoothing - that's a huge question. – Tony Delroy Jun 27 '14 at 11:00

1 Answers1

5

16-bit PCM has basically the same data bits and additional bits on the least significant bit side to specify the value and add accuracy and detail. Then 8-bit PCM is typically unsigned value with a centerpoint of 0x80, and 16-bit (also applicable to higher bitnesses) PCM is signed integer, so the conversion formula is:

UINT8 sample8 = ...;
INT16 sample16 = (INT16) (sample8 - 0x80) << 8;
Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • The shift is efficient, but does it make sense to scale the value such that 255 maps to 32767 instead of 32512? (and conversely clamp -128 to -127 so that it doesn't underflow from -33025 to 32511) – Dwayne Robinson Jan 08 '21 at 10:37
  • 1
    @DwayneRobinson: I might be mistaken here, but as far as I remember full scale -1.0/+1.0 corresponds to -0x7F/+0x7F and -0x7FFF/+0x7FFF respectively. There have been normative definitions for this. Simple shift up thus is not even supposed to deal with `MIN_INT8` and `MIN_INT16` values. If you are to clamp (more sophisticated bit math than just shift), it makes sense for me to clamp those asymmetric values out. – Roman R. Jan 08 '21 at 10:48