1

In AudioStreamBasicDescription struct:

struct AudioStreamBasicDescription {
    Float64 mSampleRate;
    UInt32  mFormatID;
    UInt32  mFormatFlags;
    UInt32  mBytesPerPacket;
    UInt32  mFramesPerPacket;
    UInt32  mBytesPerFrame;
    UInt32  mChannelsPerFrame;
    UInt32  mBitsPerChannel;
    UInt32  mReserved; 
};

if we know nChannelsPerFrame and mBitsPerChannels, we can calculate mBytesPerFrame like this: mBytesPerFrame = mBitsPerChannels * mChannelsPerFrame / 8 (correct me if I'm wrong)

I believe that all of the fields exist for some reason. What is it for mBytesPerFrame?

justin
  • 104,054
  • 14
  • 179
  • 226
jAckOdE
  • 2,402
  • 8
  • 37
  • 67

1 Answers1

2

Yes. The field can be used to aid in describing packing and alignment of LPCM sample data/frames. That's also mandatory for describing some external LPCM representations.

For example, you can specify a 20 bit sample size, but an implementation may favor to represent/transfer/store that using 3 bytes, or 24 bits (ignoring 4 bits per sample).

justin
  • 104,054
  • 14
  • 179
  • 226
  • the similar question, why do we need mBytesPerPacket if we already have mFramesPerPacket and mBytesPerFrame? – jAckOdE Nov 18 '12 at 14:36
  • @jAckOdE you're welcome. there's overlap and seemingly redundant fields because the ASBD can represent LPCM and basic VBR formats. `mBytesPerPacket` is especially useful for defining an abstract description of basic VBR data without ambiguity. – justin Nov 19 '12 at 00:48