linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Subject: [WIP] [PATCH v0.0-20200229 09/11] ez: lzma: checkpoint feature for range encoder
Date: Sat, 29 Feb 2020 12:50:15 +0800	[thread overview]
Message-ID: <20200229045017.12424-10-hsiangkao@aol.com> (raw)
In-Reply-To: <20200229045017.12424-1-hsiangkao@aol.com>

which is used to save the current state of range
encoder for later recovery in order to implement
LZMA fixed-sized output compression.

Signed-off-by: Gao Xiang <hsiangkao@aol.com>
---
 lzma/rc_encoder_ckpt.h | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 lzma/rc_encoder_ckpt.h

diff --git a/lzma/rc_encoder_ckpt.h b/lzma/rc_encoder_ckpt.h
new file mode 100644
index 0000000..415bf0c
--- /dev/null
+++ b/lzma/rc_encoder_ckpt.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/*
+ * ez/lzma/rc_encoder_ckpt.h - checkpoint for range encoder
+ *
+ * Copyright (C) 2020 Gao Xiang <hsiangkao@aol.com>
+ */
+#ifndef __EZ_LZMA_RC_ENCODER_CKPT_H
+#define __EZ_LZMA_RC_ENCODER_CKPT_H
+
+#include "rc_encoder.h"
+
+struct lzma_rc_ckpt {
+	uint64_t low;
+	uint64_t extended_bytes;
+	uint32_t range;
+	uint8_t firstbyte;
+};
+
+void rc_write_checkpoint(struct lzma_rc_encoder *rc, struct lzma_rc_ckpt *cp)
+{
+	*cp = (struct lzma_rc_ckpt) { .low = rc->low,
+				      .extended_bytes = rc->extended_bytes,
+				      .range = rc->range,
+				      .firstbyte = rc->firstbyte
+	};
+}
+
+void rc_restore_checkpoint(struct lzma_rc_encoder *rc, struct lzma_rc_ckpt *cp)
+{
+	rc->low = cp->low;
+	rc->extended_bytes = cp->extended_bytes;
+	rc->range = cp->range;
+	rc->firstbyte = cp->firstbyte;
+
+	rc->pos = 0;
+	rc->count = 0;
+}
+
+#endif
+
-- 
2.20.1


  parent reply	other threads:[~2020-02-29  4:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200229045017.12424-1-hsiangkao.ref@aol.com>
2020-02-29  4:50 ` [WIP] [PATCH v0.0-20200229 00/11] ez: LZMA fixed-sized output compression Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 01/11] ez: add basic source files Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 02/11] ez: add helpers for unaligned accesses Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 03/11] ez: introduce bitops header file Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 04/11] ez: lzma: add range encoder Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 05/11] ez: lzma: add common header file Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 06/11] ez: lzma: add byte hashtable generated with CRC32 Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 07/11] ez: lzma: add LZMA matchfinder Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 08/11] ez: lzma: add LZMA encoder Gao Xiang via Linux-erofs
2020-02-29  4:50   ` Gao Xiang via Linux-erofs [this message]
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 10/11] ez: lzma: add fixed-sized output compression Gao Xiang via Linux-erofs
2020-02-29  4:50   ` [WIP] [PATCH v0.0-20200229 11/11] ez: lzma: add test program Gao Xiang via Linux-erofs
2020-02-29  4:58   ` [WIP] [PATCH v0.0-20200229 00/11] ez: LZMA fixed-sized output compression Eric Biggers
2020-02-29  5:27     ` Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200229045017.12424-10-hsiangkao@aol.com \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=hsiangkao@aol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).