Perfect Clarity Audio

From MultimediaWiki
Jump to navigation Jump to search
  • Extension: pca
  • Company: Sony
  • TwoCC: 0x1971

This format, originally known as Sound Forge lossless audio, is a simple lossless codec for 16- or 24-bit audio. Despite the extension, pca files are normal WAV files with variable-length frames.

Flags stored in extradata may signal the following features being enabled:

  • 1 -- use M/S decorrelation
  • 2 -- LPC is enabled
  • 4 -- CRC present?

Frame format (all values are little-endian, 'C' means number of channels):

 (intra frame only) 4 bytes -- 0xFFFFFFFF
 (intra frame only) 4x4xC bytes -- history samples for each channel
 2 bytes -- number of samples? (negative value is used to signal something)
 2 bytes -- frame size
 C bytes -- Rice code parameter(s)
 C bytes -- filter order/value
 (if LPC is enabled) 4xC bytes -- LPC filter coefficient (signed bytes)
 (if something is enabled) 4 bytes -- CRC?

If filter order is 5, block is not coded, otherwise frame data consists of coefficients coded as Rice codes, data is stored per channel. Values are read MSB first, codes are re-interpreted as signed with the sign in low bit (e.g. 0 -> 0, 1 -> -1, 2 -> 1 ...).

If LPC is enabled it's applied before fixed predictor in the form of coef[i] -= (coef[i-1]*filt[0] + ... + coef[i-4]*filt[3]) >> 5.

Fixed prediction seems to be borrowed from Shorten:

  • 0 -- no prediction
  • 1 -- coef[i] += coef[i-1]
  • 2 -- coef[i] += coef[i-1] * 2 - coef[i-2]
  • 3 -- coef[i] += coef[i-1] * 3 - coef[i-2] * 3 + coef[i-3]
  • 4 -- coef[i] += coef[i-1] * 4 - coef[i-2] * 6 + coef[i-3] * 4 - coef[i-4]

When channel decorrelation is present, L = (M * 2 + S) / 2, R = (M * 2 - S) / 2 with different rounding mode depending on signedness and low bit of the values before division.

16-bit audio is output as low bits of the decoded values, 24-bit audio is clipped to the range first.