use FLAC__format_seektable_is_legal()
This commit is contained in:
parent
f31f55478d
commit
0833f34542
@ -575,27 +575,10 @@ FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *ob
|
||||
|
||||
FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object)
|
||||
{
|
||||
unsigned i;
|
||||
FLAC__uint64 prev_sample_number = 0;
|
||||
FLAC__bool got_prev = false;
|
||||
|
||||
FLAC__ASSERT(0 != object);
|
||||
FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
|
||||
|
||||
{
|
||||
const FLAC__StreamMetadata_SeekTable *seek_table = &object->data.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;
|
||||
return FLAC__format_seektable_is_legal(&object->data.seek_table);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy)
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <stdlib.h> /* for malloc() */
|
||||
#include <string.h> /* for memcpy() */
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/metadata.h" /* for FLAC__metadata_object_seektable_is_legal() */
|
||||
#include "protected/stream_encoder.h"
|
||||
#include "private/bitbuffer.h"
|
||||
#include "private/bitmath.h"
|
||||
@ -279,7 +278,7 @@ FLAC__StreamEncoderState FLAC__stream_encoder_init(FLAC__StreamEncoder *encoder)
|
||||
if(encoder->protected_->bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || encoder->protected_->bits_per_sample > FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE)
|
||||
return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_BITS_PER_SAMPLE;
|
||||
|
||||
if(!FLAC__format_is_valid_sample_rate(encoder->protected_->sample_rate))
|
||||
if(!FLAC__format_sample_rate_is_valid(encoder->protected_->sample_rate))
|
||||
return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_SAMPLE_RATE;
|
||||
|
||||
if(encoder->protected_->blocksize < FLAC__MIN_BLOCK_SIZE || encoder->protected_->blocksize > FLAC__MAX_BLOCK_SIZE)
|
||||
@ -337,7 +336,7 @@ FLAC__StreamEncoderState FLAC__stream_encoder_init(FLAC__StreamEncoder *encoder)
|
||||
if(encoder->protected_->metadata[i]->type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||
return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_METADATA;
|
||||
else if(encoder->protected_->metadata[i]->type == FLAC__METADATA_TYPE_SEEKTABLE) {
|
||||
if(!FLAC__metadata_object_seektable_is_legal(encoder->protected_->metadata[i]))
|
||||
if(!FLAC__format_seektable_is_legal(&encoder->protected_->metadata[i]->data.seek_table))
|
||||
return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_METADATA;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user