/* sample rate */
if(!read_little_endian_uint32(infile, &xx, false, encoder_wrapper.inbasefilename))
goto wav_abort_;
- if(!FLAC__format_is_valid_sample_rate(xx)) {
+ if(!FLAC__format_sample_rate_is_valid(xx)) {
fprintf(stderr, "%s: ERROR: unsupported sample rate %u\n", encoder_wrapper.inbasefilename, (unsigned)xx);
goto wav_abort_;
}
void StreamInfo::set_sample_rate(unsigned value)
{
FLAC__ASSERT(is_valid());
- FLAC__ASSERT(FLAC__format_is_valid_sample_rate(value));
+ FLAC__ASSERT(FLAC__format_sample_rate_is_valid(value));
object_->data.stream_info.sample_rate = value;
}
*/
#include <stdio.h>
+#include "FLAC/assert.h"
#include "FLAC/format.h"
const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
"VORBIS_COMMENT"
};
-FLAC__bool FLAC__format_is_valid_sample_rate(unsigned sample_rate)
+FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate)
{
if(
sample_rate == 0 ||
else
return true;
}
+
+FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table)
+{
+ unsigned i;
+ FLAC__uint64 prev_sample_number = 0;
+ FLAC__bool got_prev = false;
+
+ FLAC__ASSERT(0 != seek_table);
+
+ for(i = 0; i < seek_table->num_points; i++) {
+ if(got_prev) {
+ if(seek_table->points[i].sample_number <= prev_sample_number)
+ return false;
+ }
+ prev_sample_number = seek_table->points[i].sample_number;
+ got_prev = true;
+ }
+
+ return true;
+}
FLAC__ASSERT(metadata->data.stream_info.max_framesize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN));
if(!FLAC__bitbuffer_write_raw_uint32(bb, metadata->data.stream_info.max_framesize, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN))
return false;
- FLAC__ASSERT(FLAC__format_is_valid_sample_rate(metadata->data.stream_info.sample_rate));
+ FLAC__ASSERT(FLAC__format_sample_rate_is_valid(metadata->data.stream_info.sample_rate));
if(!FLAC__bitbuffer_write_raw_uint32(bb, metadata->data.stream_info.sample_rate, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN))
return false;
FLAC__ASSERT(metadata->data.stream_info.channels > 0);
if(!FLAC__bitbuffer_write_raw_uint32(bb, u, FLAC__FRAME_HEADER_BLOCK_SIZE_LEN))
return false;
- FLAC__ASSERT(FLAC__format_is_valid_sample_rate(header->sample_rate));
+ FLAC__ASSERT(FLAC__format_sample_rate_is_valid(header->sample_rate));
sample_rate_hint = 0;
switch(header->sample_rate) {
case 8000: u = 4; break;