float _af_format_sample_size (const AudioFormat *fmt, bool stretch3to4) { const CompressionUnit *unit = _af_compression_unit_from_id(fmt->compressionType); float squishFactor = unit->squishFactor; return _af_format_sample_size_uncompressed(fmt, stretch3to4) / squishFactor; }
float _af_format_sample_size (_AudioFormat *fmt, bool stretch3to4) { int compressionIndex; float squishFactor; compressionIndex = _af_compression_index_from_id(fmt->compressionType); squishFactor = _af_compression[compressionIndex].squishFactor; return _af_format_sample_size_uncompressed(fmt, stretch3to4) / squishFactor; }
/* Set the sampleFormat and sampleWidth fields in f, and set the PCM info to the appropriate default values for the given sample format and sample width. */ status _af_set_sample_format (AudioFormat *f, int sampleFormat, int sampleWidth) { switch (sampleFormat) { case AF_SAMPFMT_UNSIGNED: case AF_SAMPFMT_TWOSCOMP: if (sampleWidth < 1 || sampleWidth > 32) { _af_error(AF_BAD_SAMPFMT, "illegal sample width %d for integer data", sampleWidth); return AF_FAIL; } else { int bytes; f->sampleFormat = sampleFormat; f->sampleWidth = sampleWidth; bytes = _af_format_sample_size_uncompressed(f, false); if (sampleFormat == AF_SAMPFMT_TWOSCOMP) f->pcm = _af_default_signed_integer_pcm_mappings[bytes]; else f->pcm = _af_default_unsigned_integer_pcm_mappings[bytes]; } break; case AF_SAMPFMT_FLOAT: f->sampleFormat = sampleFormat; f->sampleWidth = 32; f->pcm = _af_default_float_pcm_mapping; break; case AF_SAMPFMT_DOUBLE: f->sampleFormat = sampleFormat; f->sampleWidth = 64; /*for convenience */ f->pcm = _af_default_double_pcm_mapping; break; default: _af_error(AF_BAD_SAMPFMT, "unknown sample format %d", sampleFormat); return AF_FAIL; } return AF_SUCCEED; }
int _af_format_frame_size_uncompressed (const AudioFormat *fmt, bool stretch3to4) { return _af_format_sample_size_uncompressed(fmt, stretch3to4) * fmt->channelCount; }