diff --git a/contrib/seekable_format/examples/Makefile b/contrib/seekable_format/examples/Makefile index c560eb075..b57774ef3 100644 --- a/contrib/seekable_format/examples/Makefile +++ b/contrib/seekable_format/examples/Makefile @@ -23,11 +23,11 @@ default: all all: seekable_compression seekable_decompression -seekable_compression : seekable_compression.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(SEEKABLE_OBJS) $^ $(LDFLAGS) -o $@ +seekable_compression : seekable_compression.c $(SEEKABLE_OBJS) + $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ -seekable_decompression : seekable_decompression.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(SEEKABLE_OBJS) $^ $(LDFLAGS) -o $@ +seekable_decompression : seekable_decompression.c $(SEEKABLE_OBJS) + $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ clean: @rm -f core *.o tmp* result* *.zst \ diff --git a/contrib/seekable_format/examples/seekable_compression b/contrib/seekable_format/examples/seekable_compression deleted file mode 100755 index 88e1d2949..000000000 Binary files a/contrib/seekable_format/examples/seekable_compression and /dev/null differ diff --git a/contrib/seekable_format/zstd_seekable_compression_format.md b/contrib/seekable_format/zstd_seekable_compression_format.md index fd0593f9a..cc98150ce 100644 --- a/contrib/seekable_format/zstd_seekable_compression_format.md +++ b/contrib/seekable_format/zstd_seekable_compression_format.md @@ -42,13 +42,16 @@ The structure of the seek table frame is as follows: __`Skippable_Magic_Number`__ -Value : 0x184D2A5?, which means any value from 0x184D2A50 to 0x184D2A5F. -All 16 values are valid to identify a skippable frame. +Value : 0x184D2A5E. This is for compatibility with [Zstandard skippable frames]. +Since it is legal for other Zstandard skippable frames to use the same +magic number, it is not recommended for a decoder to recognize frames +solely on this. __`Frame_Size`__ -The total size of the skippable frame, not including the `Skippable_Magic_Number` or `Frame_Size`. This is for compatibility with [Zstandard skippable frames]. +The total size of the skippable frame, not including the `Skippable_Magic_Number` or `Frame_Size`. +This is for compatibility with [Zstandard skippable frames]. [Zstandard skippable frames]: https://github.com/facebook/zstd/blob/master/doc/zstd_compression_format.md#skippable-frames @@ -59,6 +62,12 @@ The seek table footer format is as follows: |------------------|-----------------------|-----------------------| | 4 bytes | 1 byte | 4 bytes | +__`Seekable_Magic_Number`__ + +Value : 0x8F92EAB1. +This value must be the last bytes present in the compressed file so that decoders +can efficiently find it and determine if there is an actual seek table present. + __`Number_Of_Chunks`__ The number of stored chunks in the data. diff --git a/contrib/seekable_format/zstdseek_compress.c b/contrib/seekable_format/zstdseek_compress.c index 2504287cd..44dd4afca 100644 --- a/contrib/seekable_format/zstdseek_compress.c +++ b/contrib/seekable_format/zstdseek_compress.c @@ -247,7 +247,7 @@ static size_t ZSTD_seekable_writeSeekTable(ZSTD_seekable_CStream* zcs, ZSTD_outB } \ } while (0) - st_write32(ZSTD_MAGIC_SKIPPABLE_START, 0); + st_write32(ZSTD_MAGIC_SKIPPABLE_START | 0xE, 0); st_write32(seekTableLen - ZSTD_skippableHeaderSize, 4); while (zcs->chunkDSize < zcs->chunklog.size) { diff --git a/contrib/seekable_format/zstdseek_decompress.c b/contrib/seekable_format/zstdseek_decompress.c index 3cb851ea5..2b97480f5 100644 --- a/contrib/seekable_format/zstdseek_decompress.c +++ b/contrib/seekable_format/zstdseek_decompress.c @@ -39,7 +39,7 @@ static U32 ZSTD_seekable_offsetToChunk(const seekTable_t* table, U64 pos) U32 hi = table->tableLen; while (lo + 1 < hi) { - U32 mid = lo + ((hi - lo) >> 1); + U32 const mid = lo + ((hi - lo) >> 1); if (table->entries[mid].dOffset <= pos) { lo = mid; } else { @@ -139,7 +139,7 @@ size_t ZSTD_seekable_loadSeekTable(ZSTD_seekable_DStream* zds, const void* src, if (srcSize < frameSize) return frameSize; - if ((MEM_readLE32(base) & 0xFFFFFFF0U) != ZSTD_MAGIC_SKIPPABLE_START) { + if (MEM_readLE32(base) != (ZSTD_MAGIC_SKIPPABLE_START | 0xE)) { return ERROR(prefix_unknown); } if (MEM_readLE32(base+4) + ZSTD_skippableHeaderSize != frameSize) { diff --git a/doc/README.md b/doc/README.md index 6f761b33e..47cfe3617 100644 --- a/doc/README.md +++ b/doc/README.md @@ -17,3 +17,4 @@ __`zstd_manual.html`__ : Documentation on the functions found in `zstd.h`. See [http://zstd.net/zstd_manual.html](http://zstd.net/zstd_manual.html) for the manual released with the latest official `zstd` release. +