+bool DecoderStack::index_entry_start_sample_gt(
+ const uint64_t sample, const size_t index) const
+{
+ assert(index < _annotations.size());
+ return _annotations[index].start_sample() > sample;
+}
+
+bool DecoderStack::index_entry_end_sample_lt(
+ const size_t index, const uint64_t sample) const
+{
+ assert(index < _annotations.size());
+ return _annotations[index].end_sample() < sample;
+}
+
+bool DecoderStack::index_entry_end_sample_gt(
+ const uint64_t sample, const size_t index) const
+{
+ assert(index < _annotations.size());
+ return _annotations[index].end_sample() > sample;
+}
+
+void DecoderStack::insert_annotation_into_start_index(
+ const pv::data::decode::Annotation &a, const size_t storage_offset)
+{
+ vector<size_t>::iterator i = _ann_start_index.end();
+ if (!_ann_start_index.empty() &&
+ _annotations[_ann_start_index.back()].start_sample() >
+ a.start_sample())
+ i = upper_bound(_ann_start_index.begin(),
+ _ann_start_index.end(), a.start_sample(),
+ bind(&DecoderStack::index_entry_start_sample_gt,
+ this, _1, _2));
+
+ _ann_start_index.insert(i, storage_offset);
+}
+
+void DecoderStack::insert_annotation_into_end_index(
+ const pv::data::decode::Annotation &a, const size_t storage_offset)
+{
+ vector<size_t>::iterator i = _ann_end_index.end();
+ if (!_ann_end_index.empty() &&
+ _annotations[_ann_end_index.back()].end_sample() <
+ a.end_sample())
+ i = upper_bound(_ann_end_index.begin(),
+ _ann_end_index.end(), a.end_sample(),
+ bind(&DecoderStack::index_entry_end_sample_gt,
+ this, _1, _2));
+
+ _ann_end_index.insert(i, storage_offset);
+}
+