1 #ifndef _JPEG2000_PACKET_INDEX_H_
2 #define _JPEG2000_PACKET_INDEX_H_
34 vector<FileSegment>
aux;
57 assert(max_offset > 0);
61 while(max_offset > 0) {
65 offsets.set_num_bytes(num_bytes);
83 for(vector<FileSegment>::const_iterator i = index.
aux.begin(); i != index.
aux.end(); i++)
96 assert(segment.
offset >= MINIMUM_OFFSET);
98 int last = aux.size() - 1;
101 aux.push_back(segment);
102 offsets.push_back(0);
105 if(aux[last].IsContiguousTo(segment)) {
106 offsets.back() = aux[last].offset;
107 offsets.push_back(last);
111 assert(last < (MINIMUM_OFFSET - 1));
113 offsets.push_back(last + 1);
114 aux.push_back(segment);
126 return offsets.size();
145 uint64_t off_i = offsets[i];
147 if(off_i < MINIMUM_OFFSET)
return aux[off_i];
149 uint64_t off_i1 = offsets[i + 1];
151 if(off_i1 < MINIMUM_OFFSET)
152 off_i1 = aux[off_i1].
offset;
void clear()
Clears the content.
Definition: vint_vector.h:130
FileSegment operator[](int i) const
Operator used for accessing the items.
Definition: packet_index.h:143
This class has been implemented with the same philosophy that the class STL vector, but specifically designed to store integers with a length in bytes that can be not multiple from 2 (e.g.
Definition: vint_vector.h:24
Class used for indexing the packets of a codestream image.
Definition: packet_index.h:22
Identifies a data segment of a file.
Definition: file_segment.h:20
uint64_t offset
Offset of the data segment.
Definition: file_segment.h:23
vector< FileSegment > aux
Vector of file segments to handle the different sets of packets that are not contiguous.
Definition: packet_index.h:34
vint_vector offsets
Vector of packet offsets.
Definition: packet_index.h:28
const PacketIndex & operator=(const PacketIndex &index)
Copy assignment.
Definition: packet_index.h:79
PacketIndex()
Empty constructor.
Definition: packet_index.h:47
PacketIndex(uint64_t max_offset)
Initializes the object.
Definition: packet_index.h:55
virtual ~PacketIndex()
Definition: packet_index.h:158
int Size() const
Returns the number of elements of the vector.
Definition: packet_index.h:124
void Clear()
Clears the content.
Definition: packet_index.h:132
PacketIndex(const PacketIndex &index)
Copy constructor.
Definition: packet_index.h:71
PacketIndex & Add(const FileSegment &segment)
Adds a new packet segment to the index.
Definition: packet_index.h:94