Skip to content

Commit 9178830

Browse files
Add MSF_SKIPADJACENTDUPLICATES to skip adjacent duplicate records while populating a MS3TraceList
1 parent 14a4d3a commit 9178830

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
2025.303:
22
- Fix byte swapping in ms3_detect() for v3 records for big-endian systems.
3+
- Add MSF_SKIPADJACENTDUPLICATES to skip adjacent duplicate records while
4+
populating a MS3TraceList.
35

46
2025.298: v3.1.10
57
- Add MSF_SPLITISVERSION flag to control using the splitversion value as the

fileutils.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ ms3_readtracelist_timewin (MS3TraceList **ppmstl, const char *mspath, const MS3T
664664
* @param[in] flags
665665
* @parblock
666666
* - \c ::MSF_RECORDLIST : Build a ::MS3RecordList for each ::MS3TraceSeg
667+
* - \c ::MSF_SKIPADJACENTDUPLICATES : Skip adjacent duplicate records
667668
* - Flags supported by msr3_parse()
668669
* - Flags supported by mstl3_addmsr()
669670
* @endparblock
@@ -688,6 +689,7 @@ ms3_readtracelist_selection (MS3TraceList **ppmstl, const char *mspath,
688689
MS3RecordPtr *recordptr = NULL;
689690
uint32_t dataoffset;
690691
uint32_t datasize;
692+
uint32_t previous_crc = 0;
691693
int retcode;
692694

693695
if (!ppmstl)
@@ -712,6 +714,18 @@ ms3_readtracelist_selection (MS3TraceList **ppmstl, const char *mspath,
712714
while ((retcode = ms3_readmsr_selection (&msfp, &msr, mspath, flags, selections, verbose)) ==
713715
MS_NOERROR)
714716
{
717+
if (flags & MSF_SKIPADJACENTDUPLICATES)
718+
{
719+
uint32_t crc = ms_crc32c ((const uint8_t *)msr->record, msr->reclen, 0);
720+
721+
if (crc == previous_crc)
722+
{
723+
continue;
724+
}
725+
726+
previous_crc = crc;
727+
}
728+
715729
seg = mstl3_addmsr_recordptr (*ppmstl, msr, (flags & MSF_RECORDLIST) ? &recordptr : NULL,
716730
splitversion, 1, flags, tolerance);
717731

libmseed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ extern void *libmseed_memory_prealloc (void *ptr, size_t size, size_t *currentsi
15611561
0x0400 //!< [TraceList] Store update time (as nstime_t) at ::MS3TraceSeg.prvtptr
15621562
#define MSF_SPLITISVERSION \
15631563
0x0800 //!< [TraceList] Use the splitversion value as version instead of record version
1564+
#define MSF_SKIPADJACENTDUPLICATES 0x1000 //!< [TraceList] Skip adjacent duplicate records
15641565
/** @} */
15651566

15661567
#ifdef __cplusplus

0 commit comments

Comments
 (0)