made sure dictionary ID was being written in the frame header of each file

This commit is contained in:
Paul Cruz 2017-06-08 17:27:15 -07:00
parent 233ee5334e
commit 125ed59968

View File

@ -240,7 +240,7 @@ struct {
} opts; /* advanced options on generation */ } opts; /* advanced options on generation */
/* Generate and write a random frame header */ /* Generate and write a random frame header */
static void writeFrameHeader(U32* seed, frame_t* frame, int genDict) static void writeFrameHeader(U32* seed, frame_t* frame, int genDict, size_t dictSize)
{ {
BYTE* const op = frame->data; BYTE* const op = frame->data;
size_t pos = 0; size_t pos = 0;
@ -306,17 +306,18 @@ static void writeFrameHeader(U32* seed, frame_t* frame, int genDict)
pos += 4; pos += 4;
{ {
int dictBits = genDict ? 3 : 0;
BYTE const frameHeaderDescriptor = BYTE const frameHeaderDescriptor =
(BYTE) ((fcsCode << 6) | (singleSegment << 5) | (1 << 2)); (BYTE) ((fcsCode << 6) | (singleSegment << 5) | (1 << 2) | dictBits);
if(genDict)
frameHeaderDescriptor += 3; /* set lower bits for dictionary ID */
op[pos++] = frameHeaderDescriptor; op[pos++] = frameHeaderDescriptor;
} }
if (!singleSegment) { if (!singleSegment) {
op[pos++] = windowByte; op[pos++] = windowByte;
} }
if(genDict) {
MEM_writeLE32(op + pos, (U32) dictSize);
}
if (contentSizeFlag) { if (contentSizeFlag) {
switch (fcsCode) { switch (fcsCode) {
default: /* Impossible */ default: /* Impossible */
@ -1129,7 +1130,7 @@ static U32 generateFrame(U32 seed, frame_t* fr, int genDict, size_t dictSize)
DISPLAYLEVEL(1, "frame seed: %u\n", seed); DISPLAYLEVEL(1, "frame seed: %u\n", seed);
initFrame(fr); initFrame(fr);
writeFrameHeader(&seed, fr, genDict); writeFrameHeader(&seed, fr, genDict, dictSize);
writeBlocks(&seed, fr); writeBlocks(&seed, fr);
writeChecksum(fr); writeChecksum(fr);