Remove stream CRC and optimize CRC compute CRC32C using two lanes

This commit is contained in:
Andrea Mazzoleni 2026-09-10 07:39:21 +02:00
parent 581ec4e156
commit a01ec45f14
7 changed files with 196 additions and 129 deletions

View file

@ -68,7 +68,6 @@ STREAM* sopen_read(const char* file, int flags)
s->offset_uncached = 0;
s->crc = 0;
s->crc_uncached = 0;
s->crc_stream = CRC_IV;
return s;
}
@ -100,7 +99,6 @@ STREAM* sopen_multi_write(unsigned count, int flags)
s->offset_uncached = 0;
s->crc = 0;
s->crc_uncached = 0;
s->crc_stream = CRC_IV;
return s;
}
@ -389,12 +387,6 @@ uint32_t scrc(STREAM* s)
return crc32c(s->crc_uncached, s->buffer, s->pos - s->buffer);
}
uint32_t scrc_stream(STREAM* s)
{
assert(s->flags & STREAM_FLAGS_CRC);
return s->crc_stream ^ CRC_IV;
}
int sgetc_uncached(STREAM* s)
{
/* if at the end of the buffer, fill it */
@ -735,10 +727,6 @@ int swrite_uncached(const void* void_data, size_t size, STREAM* f)
if (available > size)
available = size;
/* compute the independent CRC before copying to detect buffer corruption */
if (f->flags & STREAM_FLAGS_CRC)
f->crc_stream = crc32c_plain(f->crc_stream, data, available);
memcpy(f->pos, data, available);
f->pos += available;
data += available;