10 #ifndef __XMA2DEFS_INCLUDED__ 11 #define __XMA2DEFS_INCLUDED__ 138 #define XMA_OUTPUT_SAMPLE_BYTES 2u 139 #define XMA_OUTPUT_SAMPLE_BITS (XMA_OUTPUT_SAMPLE_BYTES * 8u) 142 #define XMA_BYTES_PER_PACKET 2048u 143 #define XMA_BITS_PER_PACKET (XMA_BYTES_PER_PACKET * 8u) 146 #define XMA_PACKET_HEADER_BYTES 4u 147 #define XMA_PACKET_HEADER_BITS (XMA_PACKET_HEADER_BYTES * 8u) 150 #define XMA_SAMPLES_PER_FRAME 512u 153 #define XMA_SAMPLES_PER_SUBFRAME 128u 156 #define XMA_READBUFFER_MAX_PACKETS 4095u 157 #define XMA_READBUFFER_MAX_BYTES (XMA_READBUFFER_MAX_PACKETS * XMA_BYTES_PER_PACKET) 160 #define XMA_WRITEBUFFER_MAX_BYTES (31u * 256u) 163 #define XMA_WRITEBUFFER_BYTE_ALIGNMENT 256u 166 #define XMA_MIN_SUBFRAMES_TO_DECODE 1u 167 #define XMA_MAX_SUBFRAMES_TO_DECODE 8u 168 #define XMA_OPTIMAL_SUBFRAMES_TO_DECODE 4u 171 #define XMA_MAX_LOOPCOUNT 254u 172 #define XMA_INFINITE_LOOP 255u 185 #define WAVE_FORMAT_XMA2 0x166 219 #ifndef WAVE_FORMAT_XMA 220 #define WAVE_FORMAT_XMA 0x0165 224 #ifndef XMA_SPEAKER_LEFT 225 #define XMA_SPEAKER_LEFT 0x01 226 #define XMA_SPEAKER_RIGHT 0x02 227 #define XMA_SPEAKER_CENTER 0x04 228 #define XMA_SPEAKER_LFE 0x08 229 #define XMA_SPEAKER_LEFT_SURROUND 0x10 230 #define XMA_SPEAKER_RIGHT_SURROUND 0x20 231 #define XMA_SPEAKER_LEFT_BACK 0x40 232 #define XMA_SPEAKER_RIGHT_BACK 0x80 304 #endif // #ifndef WAVE_FORMAT_XMA 337 return (DWORD)(pPacket[0] >> 2);
342 return ((DWORD)(pPacket[0] & 0x3) << 13) |
343 ((DWORD)(pPacket[1]) << 5) |
344 ((DWORD)(pPacket[2]) >> 3);
349 return (DWORD)(pPacket[2] & 0x7);
354 return (DWORD)(pPacket[3]);
374 #define XMA_BITS_IN_FRAME_LENGTH_FIELD 15 377 #define XMA_FINAL_FRAME_MARKER 0x7FFF 387 #ifndef XMA2DEFS_ASSERT 389 #define XMA2DEFS_ASSERT ASSERT 391 #define XMA2DEFS_ASSERT(a) 405 DWORD nDesiredSample,
406 __out DWORD* pnBlockContainingSample,
407 __out DWORD* pnSampleOffsetWithinBlock
410 DWORD nPreviousTotalSamples = 0;
412 DWORD nTotalSamplesSoFar;
418 for (nBlock = 0; nBlock < nBlockCount; ++nBlock)
420 nTotalSamplesSoFar = pSeekTable[nBlock];
421 if (nTotalSamplesSoFar > nDesiredSample)
423 *pnBlockContainingSample = nBlock;
424 *pnSampleOffsetWithinBlock = nDesiredSample - nPreviousTotalSamples;
427 nPreviousTotalSamples = nTotalSamplesSoFar;
438 __in_bcount(nBitPosition / 8 + 3)
439 __in
const BYTE* pPacket,
444 DWORD nBytePosition = nBitPosition / 8;
445 DWORD nBitOffset = nBitPosition % 8;
449 nRegion = (DWORD)(pPacket[nBytePosition+0]) << 8 |
450 (DWORD)(pPacket[nBytePosition+1]);
451 return (nRegion >> (1 - nBitOffset)) & 0x7FFF;
455 nRegion = (DWORD)(pPacket[nBytePosition+0]) << 16 |
456 (DWORD)(pPacket[nBytePosition+1]) << 8 |
457 (DWORD)(pPacket[nBytePosition+2]);
458 return (nRegion >> (9 - nBitOffset)) & 0x7FFF;
468 __in_bcount(nXmaDataBytes)
const BYTE* pXmaData,
474 const BYTE* pCurrentPacket;
475 DWORD nPacketsExamined = 0;
476 DWORD nFrameCountSoFar = 0;
478 DWORD nFrameBitOffset;
501 nFramesToSkip = nDesiredFrame - nFrameCountSoFar;
507 while (nFramesToSkip--)
514 return (DWORD)(pCurrentPacket - pXmaData) * 8 + nFrameBitOffset;
532 __in_bcount(nXmaDataBytes)
const BYTE* pXmaData,
537 const BYTE* pLastPacket;
538 DWORD nBytesToNextPacket;
539 DWORD nFrameBitOffset;
540 DWORD nFramesInLastPacket;
560 pLastPacket += nBytesToNextPacket;
567 pLastPacket -= nBytesToNextPacket;
575 while (--nFramesInLastPacket)
582 return (DWORD)(pLastPacket - pXmaData) * 8 + nFrameBitOffset;
594 __in_bcount(nXmaDataBytes)
const BYTE* pXmaData,
597 DWORD nDesiredSample,
598 __out DWORD* pnBitOffset,
600 __out DWORD* pnSubFrame
612 *pnBitOffset = nBitOffset;
613 *pnSubFrame = nSubFrame;
628 DWORD dwXmaRate = 48000;
630 if (dwGeneralRate <= 24000) dwXmaRate = 24000;
631 else if (dwGeneralRate <= 32000) dwXmaRate = 32000;
632 else if (dwGeneralRate <= 44100) dwXmaRate = 44100;
645 DWORD dwStandardMask = 0;
656 return dwStandardMask;
681 #define XMASWAP2BYTES(n) ((WORD)(((n) >> 8) | (((n) & 0xff) << 8))) 682 #define XMASWAP4BYTES(n) ((DWORD)((n) >> 24 | (n) << 24 | ((n) & 0xff00) << 8 | ((n) & 0xff0000) >> 8)) 690 pXma2Format->wfx.wFormatTag =
XMASWAP2BYTES(pXma2Format->wfx.wFormatTag);
691 pXma2Format->wfx.nChannels =
XMASWAP2BYTES(pXma2Format->wfx.nChannels);
692 pXma2Format->wfx.nSamplesPerSec =
XMASWAP4BYTES(pXma2Format->wfx.nSamplesPerSec);
693 pXma2Format->wfx.nAvgBytesPerSec =
XMASWAP4BYTES(pXma2Format->wfx.nAvgBytesPerSec);
694 pXma2Format->wfx.nBlockAlign =
XMASWAP2BYTES(pXma2Format->wfx.nBlockAlign);
695 pXma2Format->wfx.wBitsPerSample =
XMASWAP2BYTES(pXma2Format->wfx.wBitsPerSample);
696 pXma2Format->wfx.cbSize =
XMASWAP2BYTES(pXma2Format->wfx.cbSize);
697 pXma2Format->NumStreams =
XMASWAP2BYTES(pXma2Format->NumStreams);
698 pXma2Format->ChannelMask =
XMASWAP4BYTES(pXma2Format->ChannelMask);
699 pXma2Format->SamplesEncoded =
XMASWAP4BYTES(pXma2Format->SamplesEncoded);
700 pXma2Format->BytesPerBlock =
XMASWAP4BYTES(pXma2Format->BytesPerBlock);
701 pXma2Format->PlayBegin =
XMASWAP4BYTES(pXma2Format->PlayBegin);
702 pXma2Format->PlayLength =
XMASWAP4BYTES(pXma2Format->PlayLength);
703 pXma2Format->LoopBegin =
XMASWAP4BYTES(pXma2Format->LoopBegin);
704 pXma2Format->LoopLength =
XMASWAP4BYTES(pXma2Format->LoopLength);
705 pXma2Format->BlockCount =
XMASWAP2BYTES(pXma2Format->BlockCount);
718 #endif // #ifndef __XMA2DEFS_INCLUDED__ XMASTREAMFORMAT XmaStreams[1]
Definition: xma2defs.h:266
int PacketSkipCount
Definition: xma2defs.h:317
WORD LargestSkip
Definition: xma2defs.h:261
__in_ecount(4) CONST FLOAT *pF
#define XMA_SAMPLES_PER_SUBFRAME
Definition: xma2defs.h:153
#define XMA_SPEAKER_RIGHT_BACK
Definition: xma2defs.h:232
struct XMA2WAVEFORMAT XMA2WAVEFORMAT
struct XMA2WAVEFORMATEX * PXMA2WAVEFORMATEX
#define XMA_SPEAKER_RIGHT
Definition: xma2defs.h:226
WAVEFORMATEX wfx
Definition: xma2defs.h:189
__inline DWORD GetXmaPacketFrameCount(__in_bcount(1) const BYTE *pPacket)
Definition: xma2defs.h:335
BYTE LoopCount
Definition: xma2defs.h:286
Definition: xma2defs.h:280
BYTE LoopCount
Definition: xma2defs.h:263
#define SPEAKER_SIDE_RIGHT
Definition: audiodefs.h:234
DWORD SampleRate
Definition: xma2defs.h:289
int PacketMetaData
Definition: xma2defs.h:316
__inline HRESULT GetXmaBlockContainingSample(DWORD nBlockCount, __in_ecount(nBlockCount) const DWORD *pSeekTable, DWORD nDesiredSample, __out DWORD *pnBlockContainingSample, __out DWORD *pnSampleOffsetWithinBlock)
Definition: xma2defs.h:402
DWORD PlayLength
Definition: xma2defs.h:205
WORD EncodeOptions
Definition: xma2defs.h:260
typedef HRESULT(WINAPI *PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)(_In_ const D3D12_ROOT_SIGNATURE_DESC *pRootSignature
BYTE LoopCount
Definition: xma2defs.h:208
BYTE SubframeData
Definition: xma2defs.h:245
#define SPEAKER_LOW_FREQUENCY
Definition: audiodefs.h:227
BYTE RESERVED
Definition: xma2defs.h:275
WORD ChannelMask
Definition: xma2defs.h:252
WORD ChannelMask
Definition: xma2defs.h:276
struct XMAWAVEFORMAT XMAWAVEFORMAT
struct XMA2STREAMFORMAT XMA2STREAMFORMAT
DWORD LoopBegin
Definition: xma2defs.h:287
Definition: xma2defs.h:237
#define XMA_SPEAKER_LEFT_BACK
Definition: xma2defs.h:231
__inline DWORD GetXmaPacketMetadata(__in_bcount(3) const BYTE *pPacket)
Definition: xma2defs.h:347
DWORD LoopEnd
Definition: xma2defs.h:288
__inline DWORD GetXmaFrameBitPosition(__in_bcount(nXmaDataBytes) const BYTE *pXmaData, DWORD nXmaDataBytes, DWORD nStreamIndex, DWORD nDesiredFrame)
Definition: xma2defs.h:467
WORD NumStreams
Definition: xma2defs.h:199
Definition: xma2defs.h:272
struct XMA2PACKET XMA2PACKET
Definition: xma2defs.h:187
struct XMASTREAMFORMAT XMASTREAMFORMAT
#define XMA_SPEAKER_RIGHT_SURROUND
Definition: xma2defs.h:230
#define XMA_SAMPLES_PER_FRAME
Definition: xma2defs.h:150
BYTE RESERVED
Definition: xma2defs.h:285
__inline HRESULT GetXmaDecodePositionForSample(__in_bcount(nXmaDataBytes) const BYTE *pXmaData, DWORD nXmaDataBytes, DWORD nStreamIndex, DWORD nDesiredSample, __out DWORD *pnBitOffset, __out DWORD *pnSubFrame)
Definition: xma2defs.h:593
WORD BitsPerSample
Definition: xma2defs.h:259
#define XMA_BYTES_PER_PACKET
Definition: xma2defs.h:142
DWORD LoopStart
Definition: xma2defs.h:242
DWORD LoopEnd
Definition: xma2defs.h:244
Definition: xma2defs.h:312
#define SPEAKER_SIDE_LEFT
Definition: audiodefs.h:233
BYTE Version
Definition: xma2defs.h:282
Definition: xma2defs.h:256
int FrameCount
Definition: xma2defs.h:314
DWORD SamplesEncoded
Definition: xma2defs.h:295
BYTE Channels
Definition: xma2defs.h:251
DWORD BlockCount
Definition: xma2defs.h:298
#define XMA_SPEAKER_LEFT
Definition: xma2defs.h:225
#define XMA2DEFS_ASSERT(a)
Definition: xma2defs.h:391
#define SPEAKER_FRONT_CENTER
Definition: audiodefs.h:226
WORD NumStreams
Definition: xma2defs.h:262
DWORD PlayBegin
Definition: xma2defs.h:204
__inline DWORD GetXmaFrameLengthInBits(__in_bcount(nBitPosition/8+3) __in const BYTE *pPacket, DWORD nBitPosition)
Definition: xma2defs.h:437
#define SPEAKER_BACK_LEFT
Definition: audiodefs.h:228
BYTE Version
Definition: xma2defs.h:264
#define XMA_SPEAKER_LFE
Definition: xma2defs.h:228
BYTE Channels
Definition: xma2defs.h:274
#define SPEAKER_FRONT_LEFT
Definition: audiodefs.h:224
DWORD BlockSizeInBytes
Definition: xma2defs.h:292
WORD BlockCount
Definition: xma2defs.h:210
DWORD EncodeOptions
Definition: xma2defs.h:290
#define SPEAKER_BACK_RIGHT
Definition: audiodefs.h:229
BYTE XmaData[XMA_BYTES_PER_PACKET - sizeof(DWORD)]
Definition: xma2defs.h:319
Definition: audiodefs.h:40
DWORD SampleRate
Definition: xma2defs.h:240
__inline DWORD GetXmaPacketFirstFrameOffsetInBits(__in_bcount(3) const BYTE *pPacket)
Definition: xma2defs.h:340
struct XMA2WAVEFORMATEX XMA2WAVEFORMATEX
BYTE EncoderVersion
Definition: xma2defs.h:209
#define WAVE_FORMAT_XMA2
Definition: xma2defs.h:185
DWORD SamplesInSource
Definition: xma2defs.h:296
#define XMA_SPEAKER_CENTER
Definition: xma2defs.h:227
XMA2STREAMFORMAT Streams[1]
Definition: xma2defs.h:300
DWORD PsuedoBytesPerSec
Definition: xma2defs.h:291
__inline DWORD GetXmaSampleRate(DWORD dwGeneralRate)
Definition: xma2defs.h:626
__inline DWORD GetXmaPacketSkipCount(__in_bcount(4) const BYTE *pPacket)
Definition: xma2defs.h:352
int FrameOffsetInBits
Definition: xma2defs.h:315
DWORD SamplesEncoded
Definition: xma2defs.h:202
__inline DWORD GetStandardChannelMaskFromXmaMask(BYTE bXmaMask)
Definition: xma2defs.h:643
WORD FormatTag
Definition: xma2defs.h:258
BYTE NumStreams
Definition: xma2defs.h:284
DWORD LoopLength
Definition: xma2defs.h:207
#define SPEAKER_FRONT_RIGHT
Definition: audiodefs.h:225
DWORD LoopBegin
Definition: xma2defs.h:206
__inline BYTE GetXmaChannelMaskFromStandardMask(DWORD dwStandardMask)
Definition: xma2defs.h:659
DWORD BytesPerBlock
Definition: xma2defs.h:203
#define XMA_PACKET_HEADER_BITS
Definition: xma2defs.h:147
__inline HRESULT LocalizeXma2Format(__inout XMA2WAVEFORMATEX *pXma2Format)
Definition: xma2defs.h:679
DWORD ChannelMask
Definition: xma2defs.h:200
#define XMA_SPEAKER_LEFT_SURROUND
Definition: xma2defs.h:229
DWORD PsuedoBytesPerSec
Definition: xma2defs.h:239
__inline DWORD GetLastXmaFrameBitPosition(__in_bcount(nXmaDataBytes) const BYTE *pXmaData, DWORD nXmaDataBytes, DWORD nStreamIndex)
Definition: xma2defs.h:531