static void ASBD_BtoN(const AudioStreamBasicDescription *infmt, AudioStreamBasicDescription *outfmt) { *(UInt64 *)&outfmt->mSampleRate = EndianU64_BtoN(*(UInt64 *)&infmt->mSampleRate); outfmt->mFormatID = EndianU32_BtoN(infmt->mFormatID); outfmt->mFormatFlags = EndianU32_BtoN(infmt->mFormatFlags); outfmt->mBytesPerPacket = EndianU32_BtoN(infmt->mBytesPerPacket); outfmt->mFramesPerPacket = EndianU32_BtoN(infmt->mFramesPerPacket); outfmt->mBytesPerFrame = EndianU32_BtoN(infmt->mBytesPerFrame); outfmt->mChannelsPerFrame = EndianU32_BtoN(infmt->mChannelsPerFrame); outfmt->mBitsPerChannel = EndianU32_BtoN(infmt->mBitsPerChannel); }
void ACFLACCodec::ParseMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize, FLAC__StreamMetadata_StreamInfo * theStreamInfo) const { FLAC__StreamMetadata_StreamInfo * tempConfig; UInt32 cookieOffset = 0; // We might get a cookie with atoms -- strip them off if (inMagicCookieDataByteSize > sizeof(FLAC__StreamMetadata_StreamInfo)) { if(EndianU32_BtoN(((AudioFormatAtom *)inMagicCookieData)->atomType) == 'frma') { cookieOffset = (sizeof(AudioFormatAtom) + sizeof(FullAtomHeader)); } } // Finally, parse the cookie for the bits we care about tempConfig = (FLAC__StreamMetadata_StreamInfo *)(&((Byte *)(inMagicCookieData))[cookieOffset]); theStreamInfo->min_blocksize = EndianU32_BtoN( tempConfig->min_blocksize ); theStreamInfo->max_blocksize = EndianU32_BtoN( tempConfig->max_blocksize ); theStreamInfo->min_framesize = EndianU32_BtoN( tempConfig->min_framesize ); theStreamInfo->max_framesize = EndianU32_BtoN( tempConfig->max_framesize ); theStreamInfo->sample_rate = EndianU32_BtoN( tempConfig->sample_rate ); theStreamInfo->channels = EndianU32_BtoN( tempConfig->channels ); theStreamInfo->bits_per_sample = EndianU32_BtoN( tempConfig->bits_per_sample ); theStreamInfo->total_samples = EndianU64_BtoN( tempConfig->total_samples ); theStreamInfo->md5sum[0] = tempConfig->md5sum[0]; theStreamInfo->md5sum[1] = tempConfig->md5sum[1]; theStreamInfo->md5sum[2] = tempConfig->md5sum[2]; theStreamInfo->md5sum[3] = tempConfig->md5sum[3]; theStreamInfo->md5sum[4] = tempConfig->md5sum[4]; theStreamInfo->md5sum[5] = tempConfig->md5sum[5]; theStreamInfo->md5sum[6] = tempConfig->md5sum[6]; theStreamInfo->md5sum[7] = tempConfig->md5sum[7]; theStreamInfo->md5sum[8] = tempConfig->md5sum[8]; theStreamInfo->md5sum[9] = tempConfig->md5sum[9]; theStreamInfo->md5sum[10] = tempConfig->md5sum[10]; theStreamInfo->md5sum[11] = tempConfig->md5sum[11]; theStreamInfo->md5sum[12] = tempConfig->md5sum[12]; theStreamInfo->md5sum[13] = tempConfig->md5sum[13]; theStreamInfo->md5sum[14] = tempConfig->md5sum[14]; theStreamInfo->md5sum[15] = tempConfig->md5sum[15]; }