mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
rename (FLAC__format_is_valid_sample_rate() to FLAC__format_sample_rate_is_valid()
This commit is contained in:
@@ -216,7 +216,7 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons
|
||||
/* 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_;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace FLAC {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/format.h"
|
||||
|
||||
const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
|
||||
@@ -111,7 +112,7 @@ const char * const FLAC__MetadataTypeString[] = {
|
||||
"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 ||
|
||||
@@ -126,3 +127,23 @@ FLAC__bool FLAC__format_is_valid_sample_rate(unsigned sample_rate)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__
|
||||
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);
|
||||
@@ -157,7 +157,7 @@ FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__bool st
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user