974
971
/* sort segments by {BodySID, IndexSID, IndexStartPosition}, remove duplicates while we're at it */
975
972
for (i = 0; i < nb_segments; i++) {
976
973
int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
978
976
for (j = 0; j < nb_segments; j++) {
979
977
MXFIndexTableSegment *s = unsorted_segments[j];
981
979
/* Require larger BosySID, IndexSID or IndexStartPosition then the previous entry. This removes duplicates.
982
980
* We want the smallest values for the keys than what we currently have, unless this is the first such entry this time around.
984
983
if ((i == 0 || s->body_sid > last_body_sid || s->index_sid > last_index_sid || s->index_start_position > last_index_start) &&
987
987
best_body_sid = s->body_sid;
988
988
best_index_sid = s->index_sid;
989
989
best_index_start = s->index_start_position;