From b77761d9173676dbc0249e9cf42082c7a9eeb203 Mon Sep 17 00:00:00 2001 From: Frederic Langlet Date: Mon, 10 May 2021 09:25:14 -0700 Subject: [PATCH] Make the bitstream version available in the context. --- io/CompressedStream.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/io/CompressedStream.go b/io/CompressedStream.go index 731f29f6..f0859c0d 100644 --- a/io/CompressedStream.go +++ b/io/CompressedStream.go @@ -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 @@ -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