]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Address PR comments and minor fixes
authorSean Purcell <me@seanp.xyz>
Wed, 12 Apr 2017 17:57:38 +0000 (10:57 -0700)
committerSean Purcell <me@seanp.xyz>
Wed, 12 Apr 2017 18:15:46 +0000 (11:15 -0700)
contrib/seekable_format/examples/Makefile
contrib/seekable_format/examples/seekable_compression [deleted file]
contrib/seekable_format/zstd_seekable_compression_format.md
contrib/seekable_format/zstdseek_compress.c
contrib/seekable_format/zstdseek_decompress.c
doc/README.md

index c560eb0752ed60f9b950ee45d42539180f06d505..b57774ef31917ee03865edb4732cb5121107bd2c 100644 (file)
@@ -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 (executable)
index 88e1d29..0000000
Binary files a/contrib/seekable_format/examples/seekable_compression and /dev/null differ
index fd0593f9ab1c1fce4b8b0391cf4e62116097aa3e..cc98150ce4c69939a6f4f78a00fc50c6eee17951 100644 (file)
@@ -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.
index 2504287cdb5440248357af76e8c0df5e887599af..44dd4afcafb876ef02fdb9cbb3667f8ce68e0bdc 100644 (file)
@@ -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) {
index 3cb851ea5a29e999286a7caf0369cdfa280e76b4..2b97480f575443230ba335a03d118eadda4348dc 100644 (file)
@@ -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) {
index 6f761b33e0dabe9a05000634fa9e6cd978aa5a96..47cfe36172af9374fc739cd6f4268694367770ad 100644 (file)
@@ -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.
 
+