Skip to content

Commit

Permalink
Make the bitstream version available in the context.
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed May 10, 2021
1 parent 65eeaab commit b77761d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions io/CompressedStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func createCompressedOutputStreamWithCtx(obs kanzi.OutputBitStream, ctx map[stri
tasks = (1 << 31) / bSize
}

ctx["bsVersion"] = int(_BITSTREAM_FORMAT_VERSION)
this := new(CompressedOutputStream)
this.obs = obs

Expand Down Expand Up @@ -885,14 +886,16 @@ func (this *CompressedInputStream) readHeader() error {
return &IOError{msg: "Invalid stream type", code: kanzi.ERR_INVALID_FILE}
}

version := this.ibs.ReadBits(4)
bsVersion := int(this.ibs.ReadBits(4))

// Sanity check
if version != _BITSTREAM_FORMAT_VERSION {
errMsg := fmt.Sprintf("Invalid bitstream, cannot read this version of the stream: %d", version)
if bsVersion != _BITSTREAM_FORMAT_VERSION {
errMsg := fmt.Sprintf("Invalid bitstream, cannot read this version of the stream: %d", bsVersion)
return &IOError{msg: errMsg, code: kanzi.ERR_STREAM_VERSION}
}

this.ctx["bsVersion"] = bsVersion

// Read block checksum
if this.ibs.ReadBit() == 1 {
var err error
Expand Down

0 comments on commit b77761d

Please sign in to comment.