BFSTP (File Format)

From Wexos's Wiki
(Redirected from BFSTP)
Jump to navigationJump to search

BFSTP (Binary caFe STream Prefetch) is a file format used together with BFSTM files on Wii U and the Nintendo Switch. It contains the sound stream which is heard in the beginning, to make sure the BFSTM is loaded smoothly.

File Format

Header

The file starts with a header. It has the following structure:

Offset Type Description
0x00 Char[4] File magic. Always FSTP in ASCII.
0x04 UInt16 Byte-order-mark. FE FF for big endian, FF FE for little endian.
0x06 UInt16 Header size. Always 0x40.
0x08 UInt32 Version number.
0x0C UInt32 Size of the file in bytes.
0x10 UInt16 Number of data blocks in the file. Always 2 (INFO and PDAT).
0x12 UInt16 Padding.
0x14 UInt16 INFO section flag. Always 0x4000.
0x16 UInt16 Padding.
0x18 Int32 INFO offset.
0x1C UInt32 INFO size.
0x20 UInt16 PDAT section flag. Always 0x4004.
0x22 UInt16 Padding.
0x24 Int32 PDAT offset.
0x28 UInt32 PDAT size.

INFO

The INFO section contains general information about the stream.

Offset Type Description
0x00 Char[4] Section magic. Always INFO in ASCII.
0x04 UInt32 Size of this section in bytes.
0x08 UInt16 Stream info flag. Always 0x4100.
0x0A UInt16 Padding.
0x0C Int32 Stream info offset, relative to 0x08 in this structure.
0x10 UInt16 Track info flag. Often not used and therefor set to 0.
0x12 UInt16 Padding.
0x14 Int32 Track info offset, relative to 0x08 in this structure.
0x18 UInt16 Channel info flag. Always 0x0101.
0x1A UInt16 Padding.
0x1C Int32 Channel info offset, relative to 0x08 in this structure.

Stream Info

Offset Type Description
0x00 Byte Sound encoding. 0 = PCM8, 1 = PCM16, 2 = DSP ADPCM, 3 = IMA ADPCM.
0x01 Byte Loop. 1 if it loops.
0x02 Byte Number of channels.
0x03 Byte Number of regions.
0x04 UInt32 Sample rate.
0x08 UInt32 Loop start.
0x0C UInt32 Loop end.
0x10 UInt32 The total number of blocks, including the padded one. If this field is N, S is the size of one block and P is the size of a last padded block, then the size of one channel is (N - 1) * S + P.
0x14 UInt32 Size of one block in bytes.
0x18 UInt32 Size of one block in samples.
0x1C UInt32 Size of the last block without padding in bytes.
0x20 UInt32 Size of the last block without padding in samples.
0x24 UInt32 Size of the last block with padding in bytes. The last block is always aligned. PCM8 audio is aligned by 0x20 and PCM16 audio is aligned by 0x04.
0x28 UInt32 Size of one channel's seek info for one block, which should be 4, given the History Info should be 4 bytes long in almost all cases.
0x2C UInt32 Seek sample interval. Unknown meaning.
0x30 UInt16 Sample data flag. Always 0x1F00.
0x32 UInt16 Padding.
0x34 Int32 Absolute sample data offset. Offset to the sample data of the first channel.
0x38 UInt16 Size of each region info. Unknown meaning.
0x3A UInt16 Padding.
0x3C UInt16 Region info flag. Often not used and therefor set to 0.
0x3E UInt16 Padding.
0x40 Int32 Region info offset.
If version ≥ 0.2.1.0
0x44 UInt32 Original loop start.
0x48 UInt32 Original loop end.
If version ≥ 0.5.1.0
0x4C UInt32 CRC-32 checksum of the BFSTM file with the checksum field set to 0.

Track Info

The INFO section links to a reference table which points to the following structure:

Offset Type Description
0x00 Byte Volume.
0x01 Byte Pan.
0x02 Byte Span.
0x03 Byte Flags.
0x04 UInt16 Global channel index table flag.
0x06 UInt16 Padding.
0x08 Int32 Offset to the global channel index table.

Global Channel Index Table

The Global Channel Index Table is used to bundle the local channel index in the track with the global channel index for the overall stream. It has the following structure:

Offset Type Description
0x00 UInt32 C = Count.
0x04 Byte[C] Items.

Channel Info

The INFO section links to a reference table which points to the following structure. The section flag is set to 0x4102.

Offset Type Description
0x00 UInt16 Section flag. Always 0x0300.
0x02 UInt16 Padding.
0x04 Int32 Offset to DSP ADPCM channel info, relative to the start of this structure.

DSP ADPCM Channel Info

Offset Type Description
0x00 UInt16[8][2] 16-bit Coefficients.
0x20 UInt16 Pred scale.
0x22 UInt16 Yn 1.
0x24 UInt16 Yn 2.
0x26 UInt16 Loop Pred Scale.
0x28 UInt16 Loop Yn 1.
0x2A UInt16 Loop Yn 2.
0x2C UInt16 Padding.

PDAT

The PDAT (Prefetch DATa) section contains the prefetch data. It has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always PDAT in ASCII.
0x04 UInt32 Size of this section in bytes.
0x08 Int32 Number of prefetch datas.

The specified number of prefetch datas follows.

Prefetch Data

Offset Type Description
0x00 UInt32 Start frame.
0x04 UInt32 Size of prefetch data in bytes.
0x08 UInt32 Reserved.
0x0C UInt16 Section flag. Always 0.
0x0E UInt16 Padding.
0x10 Int32 Prefetch data offset, relative to the start of this structure.

Version List

Version Found in
0.1.0.0
0.2.1.0
0.4.0.0
0.5.1.0
0.5.2.0

Tools

The following tools can handle BFSTP files:

  • (none)