Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Computer programs expand so as to fill the core available.


computers / comp.compression / Re: Help needed writing bit fields

SubjectAuthor
* Help needed writing bit fieldsHarry Potter
`- Re: Help needed writing bit fieldsJames D. Allen

1
Subject: Help needed writing bit fields
From: Harry Potter
Newsgroups: comp.compression
Date: Tue, 21 Sep 2021 17:58 UTC
X-Received: by 2002:ac8:66d3:: with SMTP id m19mr4272393qtp.287.1632247083836;
Tue, 21 Sep 2021 10:58:03 -0700 (PDT)
X-Received: by 2002:a05:6902:100c:: with SMTP id w12mr40208897ybt.47.1632247083625;
Tue, 21 Sep 2021 10:58:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.compression
Date: Tue, 21 Sep 2021 10:58:03 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2603:7000:1203:2375:3d65:a86f:fa96:cb91;
posting-account=xRocggoAAACFej4w6sQauoZjUP9yroE5
NNTP-Posting-Host: 2603:7000:1203:2375:3d65:a86f:fa96:cb91
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5c54ae78-8363-4f12-b840-05571a4ea0d7n@googlegroups.com>
Subject: Help needed writing bit fields
From: rose.jos...@yahoo.com (Harry Potter)
Injection-Date: Tue, 21 Sep 2021 17:58:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 0
View all headers
Hi!  I am working on file compression.  Up to now, I have been writing to a bit stream the wrong way, i.e. starting at bit 0.  Now, I need to write it starting at bit 7.  Can somebody supply the p-code on how to do it?


Subject: Re: Help needed writing bit fields
From: James D. Allen
Newsgroups: comp.compression
Date: Thu, 21 Oct 2021 05:25 UTC
References: 1
X-Received: by 2002:a05:622a:18f:: with SMTP id s15mr3779237qtw.189.1634793919526;
Wed, 20 Oct 2021 22:25:19 -0700 (PDT)
X-Received: by 2002:a25:1906:: with SMTP id 6mr3481579ybz.334.1634793919290;
Wed, 20 Oct 2021 22:25:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.compression
Date: Wed, 20 Oct 2021 22:25:19 -0700 (PDT)
In-Reply-To: <5c54ae78-8363-4f12-b840-05571a4ea0d7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:44c8:4663:d608:d48c:a9d7:8b58:bad2;
posting-account=xLsqvAoAAADY4BMAqIw3ROq0faU4tvyS
NNTP-Posting-Host: 2001:44c8:4663:d608:d48c:a9d7:8b58:bad2
References: <5c54ae78-8363-4f12-b840-05571a4ea0d7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cc804470-f5ed-47cd-96dd-51fad4e4b9ddn@googlegroups.com>
Subject: Re: Help needed writing bit fields
From: jdallen2...@yahoo.com (James D. Allen)
Injection-Date: Thu, 21 Oct 2021 05:25:19 +0000
Content-Type: text/plain; charset="UTF-8"
View all headers
On Wednesday, September 22, 2021 at 12:58:04 AM UTC+7, Harry Potter wrote:
Hi! I am working on file compression. Up to now, I have been writing to a bit stream the wrong way, i.e. starting at bit 0. Now, I need to write it starting at bit 7. Can somebody supply the p-code on how to do it?

Bits within bytes:
It does not matter whether you treat Bit 0 or Bit 7 first, as long as your decompressor
and compressor use the same approach.

If you have working code and insist on reversing the sense, a table look-up might be the
easiest way.
  unsigned char reverser[256] = {0x00, 0x80, 0x40, 0xc0, 0x20, ...

Bytes within larger units (e.g. uint32):
This is a more serious issue, if you want to be able to compress on a Big-endian machine
and decompress on Little-Endian (or vice versa).  Processing the file byte-by-byte is the
sure-fire way to bypass the issue.

Assuming C programming, do NOT use C's built-in bitfields to address these issues!
Different compilers may pack those bits in different ways.

Cheers,
James


1
rocksolid light 0.7.2
clearneti2ptor