mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
Address PR comments and minor fixes
This commit is contained in:
@ -23,11 +23,11 @@ default: all
|
|||||||
|
|
||||||
all: seekable_compression seekable_decompression
|
all: seekable_compression seekable_decompression
|
||||||
|
|
||||||
seekable_compression : seekable_compression.c
|
seekable_compression : seekable_compression.c $(SEEKABLE_OBJS)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(SEEKABLE_OBJS) $^ $(LDFLAGS) -o $@
|
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
seekable_decompression : seekable_decompression.c
|
seekable_decompression : seekable_decompression.c $(SEEKABLE_OBJS)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(SEEKABLE_OBJS) $^ $(LDFLAGS) -o $@
|
$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -f core *.o tmp* result* *.zst \
|
@rm -f core *.o tmp* result* *.zst \
|
||||||
|
Binary file not shown.
@ -42,13 +42,16 @@ The structure of the seek table frame is as follows:
|
|||||||
|
|
||||||
__`Skippable_Magic_Number`__
|
__`Skippable_Magic_Number`__
|
||||||
|
|
||||||
Value : 0x184D2A5?, which means any value from 0x184D2A50 to 0x184D2A5F.
|
Value : 0x184D2A5E.
|
||||||
All 16 values are valid to identify a skippable frame.
|
|
||||||
This is for compatibility with [Zstandard skippable frames].
|
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`__
|
__`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
|
[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 |
|
| 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`__
|
__`Number_Of_Chunks`__
|
||||||
|
|
||||||
The number of stored chunks in the data.
|
The number of stored chunks in the data.
|
||||||
|
@ -247,7 +247,7 @@ static size_t ZSTD_seekable_writeSeekTable(ZSTD_seekable_CStream* zcs, ZSTD_outB
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
st_write32(ZSTD_MAGIC_SKIPPABLE_START, 0);
|
st_write32(ZSTD_MAGIC_SKIPPABLE_START | 0xE, 0);
|
||||||
st_write32(seekTableLen - ZSTD_skippableHeaderSize, 4);
|
st_write32(seekTableLen - ZSTD_skippableHeaderSize, 4);
|
||||||
|
|
||||||
while (zcs->chunkDSize < zcs->chunklog.size) {
|
while (zcs->chunkDSize < zcs->chunklog.size) {
|
||||||
|
@ -39,7 +39,7 @@ static U32 ZSTD_seekable_offsetToChunk(const seekTable_t* table, U64 pos)
|
|||||||
U32 hi = table->tableLen;
|
U32 hi = table->tableLen;
|
||||||
|
|
||||||
while (lo + 1 < hi) {
|
while (lo + 1 < hi) {
|
||||||
U32 mid = lo + ((hi - lo) >> 1);
|
U32 const mid = lo + ((hi - lo) >> 1);
|
||||||
if (table->entries[mid].dOffset <= pos) {
|
if (table->entries[mid].dOffset <= pos) {
|
||||||
lo = mid;
|
lo = mid;
|
||||||
} else {
|
} else {
|
||||||
@ -139,7 +139,7 @@ size_t ZSTD_seekable_loadSeekTable(ZSTD_seekable_DStream* zds, const void* src,
|
|||||||
|
|
||||||
if (srcSize < frameSize) return frameSize;
|
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);
|
return ERROR(prefix_unknown);
|
||||||
}
|
}
|
||||||
if (MEM_readLE32(base+4) + ZSTD_skippableHeaderSize != frameSize) {
|
if (MEM_readLE32(base+4) + ZSTD_skippableHeaderSize != frameSize) {
|
||||||
|
@ -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
|
See [http://zstd.net/zstd_manual.html](http://zstd.net/zstd_manual.html) for
|
||||||
the manual released with the latest official `zstd` release.
|
the manual released with the latest official `zstd` release.
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user