rename (FLAC__format_is_valid_sample_rate() to FLAC__format_sample_rate_is_valid()
authorJosh Coalson <jcoalson@users.sourceforce.net>
Mon, 15 Jul 2002 05:24:56 +0000 (05:24 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Mon, 15 Jul 2002 05:24:56 +0000 (05:24 +0000)
src/flac/encode.c
src/libFLAC++/metadata.cc
src/libFLAC/format.c
src/libFLAC/stream_encoder_framing.c

index 4d7f683254fcef9ad56a8369e39b1580611ac7ab..6d76d3c6b8f4f9f19a6e8489bb53d80b817b2829 100644 (file)
@@ -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_;
                                }
index f39d7d4eca446686d2600c9e21a86bc115253cbd..c24093b084789886c1d4d03dad1b38997723638b 100644 (file)
@@ -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;
                }
 
index 6c17b602089b04a13f6e9b8fe5d668525a8a2695..d3c94c314ce949d657b0e8afa1f46e7c3eed9b1e 100644 (file)
@@ -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;
+}
index e3e3e5a4d0ccb85e7df5d4aac8e418eb806b7f39..61127ba3491c0c57831a809174e90d00e800dee3 100644 (file)
@@ -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;