pub struct SeekTable {
pub points: Contiguous<{ Self::MAX_POINTS }, SeekPoint>,
}Expand description
A SEEKTABLE metadata block
Because FLAC frames do not store their compressed length, a seek table is used for random access within a FLAC file. By mapping a sample number to a byte offset, one can quickly reach different parts of the file without decoding the whole thing.
Also note that seek point byte offsets are relative to the start of the first FLAC frame, and not relative to the start of the entire file. This allows us to change the size of the set of metadata blocks without having to recalculate the contents of the seek table.
Because the byte and sample offsets are file-specific, a seek table generated for one file should not be transferred to another FLAC file where the frames are different sizes and in different positions.
This block may occur only once in a FLAC file.
Its seekpoints occupy the entire block.
§Example
use bitstream_io::{BitReader, BitRead, BigEndian};
use flac_codec::metadata::{BlockHeader, BlockType, SeekTable, SeekPoint};
let data: &[u8] = &[
0x83, 0x00, 0x00, 0x48, // block header
// seekpoint 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x14,
// seekpoint 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
0x00, 0x14,
// seekpoint 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22,
0x00, 0x14,
// seekpoint 3
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x00, 0x14,
];
let mut r = BitReader::endian(data, BigEndian);
let header = r.parse::<BlockHeader>().unwrap();
assert_eq!(
&header,
&BlockHeader {
last: true,
block_type: BlockType::SeekTable,
size: 0x48u8.into(),
},
);
let seektable = r.parse_using::<SeekTable>(header.size).unwrap();
assert_eq!(
Vec::from(seektable.points),
vec![
SeekPoint::Defined {
sample_offset: 0x00,
byte_offset: 0x00,
frame_samples: 0x14,
},
SeekPoint::Defined {
sample_offset: 0x14,
byte_offset: 0x0c,
frame_samples: 0x14,
},
SeekPoint::Defined {
sample_offset: 0x28,
byte_offset: 0x22,
frame_samples: 0x14,
},
SeekPoint::Defined {
sample_offset: 0x3c,
byte_offset: 0x3c,
frame_samples: 0x14,
},
],
);
Fields§
§points: Contiguous<{ Self::MAX_POINTS }, SeekPoint>The seek table’s individual seek points