Commit 28e08d8f authored by Josh Coalson's avatar Josh Coalson
Browse files

bring in what was FLAC__seek_table_is_valid()

parent 6dc7934c
......@@ -151,6 +151,8 @@ namespace FLAC {
void set_point(unsigned index, const ::FLAC__StreamMetaData_SeekPoint &point);
bool insert_point(unsigned index, const ::FLAC__StreamMetaData_SeekPoint &point);
bool delete_point(unsigned index);
bool is_legal() const;
};
class VorbisComment : public Prototype {
......
......@@ -551,6 +551,7 @@ FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetaD
FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetaData *object, unsigned comment_num, FLAC__StreamMetaData_VorbisComment_Entry entry, FLAC__bool copy);
FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetaData *object, unsigned comment_num, FLAC__StreamMetaData_VorbisComment_Entry entry, FLAC__bool copy);
FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetaData *object, unsigned comment_num);
FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetaData *object);
#ifdef __cplusplus
}
......
......@@ -374,6 +374,12 @@ namespace FLAC {
return (bool)::FLAC__metadata_object_seektable_delete_point(object_, index);
}
bool SeekTable::is_legal() const
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__metadata_object_seektable_is_legal(object_);
}
//
// VorbisComment::Entry
......
......@@ -456,6 +456,33 @@ FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetaData *ob
return FLAC__metadata_object_seektable_resize_points(object, object->data.seek_table.num_points-1);
}
FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetaData *object)
{
unsigned i;
FLAC__uint64 last_sample_number = 0;
FLAC__bool got_last = 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(seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
if(got_last) {
if(seek_table->points[i].sample_number <= last_sample_number)
return false;
}
last_sample_number = seek_table->points[i].sample_number;
got_last = true;
}
}
}
return true;
}
FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetaData *object, FLAC__StreamMetaData_VorbisComment_Entry entry, FLAC__bool copy)
{
return vorbiscomment_set_entry_(object, &object->data.vorbis_comment.vendor_string, &entry, copy);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment