XWMAEncoder

Encodes an input buffer into XWMA data.

Syntax

HRESULT XWMAEncoder(
         const BYTE *pInputBuffer,
         DWORD inputBufferSize,
         const WAVEFORMATEX *pInputFormat,
         DWORD outputBitrate,
         BYTE **ppEncodedBuffer,
         DWORD *pEncodedBufferSize,
         WAVEFORMATEX **ppEncodedBufferFormat,
         DWORD *pEncodedBufferFormatSize,
         DWORD **ppDecodedPacketCumulativeBytes,
         DWORD *pDecodedPacketCumulativeBytesSize)  

Parameters

pInputBuffer
Type: BYTE *

Pointer to the input buffer containing PCM data, must contain at least one frame.

inputBufferSize
Type: DWORD 

Input buffer size in bytes.

pInputFormat
Type: WAVEFORMATEX *

Input buffer format.

outputBitrate
Type: DWORD 

Specifies requested bitrate, must be one of 20000, 32000, 48000, 64000, 96000, 160000 or 192000.

ppEncodedBuffer
Type: BYTE **

Pointer to a pointer to the encoded data.

pEncodedBufferSize
Type: DWORD *

Pointer to a DWORD containing the encoded data size, in bytes.

ppEncodedBufferFormat
Type: WAVEFORMATEX **

Pointer to a pointer to the output format structure.

pEncodedBufferFormatSize
Type: DWORD *

Pointer to a DWORD containing the output format structure size.

ppDecodedPacketCumulativeBytes
Type: DWORD **

Decoded packet cumulative data size array (use free [] to release). Each element is the number of bytes accumulated when the corresponding WMA packet is decoded in order, must have PacketCount elements. PacketCount is set in the XAUDIO2_BUFFER_WMA structure.

pDecodedPacketCumulativeBytesSize
Type: DWORD *

Size of decoded packet cumulative data (in bytes). The number of packets = *pDecodedPacketCumulativeBytesSize / sizeof(DWORD);

Return value

Type: HRESULT 

Success (S_OK) or an error code from the following table.

Error code Description
XWMA_E_UNSUPPORTED_FORMATTAG Format tag must be WAVE_FORMAT_PCM or WAVE_FORMAT_IEEE_FLOAT
XWMA_E_UNSUPPORTED_FRAMERATE nSamplesPerSec must be between 1kHz and 200kHz
XWMA_E_UNSUPPORTED_CHANNELS nChannels must be 1, 2, or 6
XWMA_E_UNSUPPORTED_BITSPERSAMPLE wBitsPerSample must be 8, 16 or 24 for integer input data or 32 for floating-point data
XWMA_E_UNSUPPORTED_BITRATE bitrate must be 20kbps, 32kbps, 48kbps, 64kbps, 96kbps, 16kbps0, or 192kbps

Remarks

Natively supported bitrates per sample rate and channel count.

Input Output options
22050Hz mono 20000
22050Hz stereo 32000
32000Hz mono 20000
32000Hz stereo 32000, 48000
44100Hz mono 32000, 48000
44100Hz stereo 32000, 48000, 96000, 192000
44100Hz 5.1 96000, 192000
48000Hz stereo 48000, 64000, 96000, 160000, 192000
48000Hz 5.1 48000, 192000

Requirements

Header: Declared in xwmaencoder.h.

Library: Use xwmaencoder.lib.