Thread View: news.software.nntp
3 messages
3 total messages
Started by Lykas
Thu, 14 Nov 2002 16:44
Idea for a efficient quasi 8bit CTE (qp-special-lite)
Author: Lykas
Date: Thu, 14 Nov 2002 16:44
Date: Thu, 14 Nov 2002 16:44
34 lines
2654 bytes
2654 bytes
In the input stream all critical characters are replaced with a
pre-defined replacement charracter(*). In order to decide later on
whether an occurrence of a replacement charracter is in fact
the replacement charracter itself or the critical charracter it
replaces, we must add a tag to any of these replacement charracters.
But instead of using a whole byte ("quote character") as in 'yenc',
is suffice to use only one bit and thus reducing the encoding
overhead by a factor of four(**). In other words every critical
character and replacement character translates to 9 bits of output.
This encoding also dosen't suffer so much from the problem with
files that contain huge amounts of critical characters, as the
input characters don't end up on byte boundaries. In this way the
method does some kind of randomization of the input stream. To add
this effect (and make performance more predictable) one can xor
every input byte with a byte counter modulo 256. Which is sort of
of xor-ing the input stream with a uniformaly distributed random
byte stream. (Of course our byte stream is not random, but it _is_
uniformaly distributed.)
For a uniformaly distributed input stream the encoding overhead is
2n/(8*256)*100%, where n is the number of critical characters. For
the pathological worst case the overhead is 1/8 = 12.5%.
I have done some tests with n=3 (i.e. '\0', '\n', '\r') on a variety
of file types (text, mpeg, mp3, jpg, gif, png, zip, gz, ...) and have
never reached an overhead bigger than that of an uniform distribution
(0.293%).
(* only 7bits of the replacement characters can be choosen arbitrary
one bit is reserved as an eventual tag bit).
(** the overhead is reduced by a factor 8 for every tag, but we must
tag the critical _and_ the replacement characters)
Re: Idea for a efficient quasi 8bit CTE (qp-special-lite)
Author: Curt Welch
Date: Thu, 14 Nov 2002 17:33
Date: Thu, 14 Nov 2002 17:33
42 lines
3002 bytes
3002 bytes
lykas@gmx.ch (Lykas) wrote: > For a uniformaly distributed input stream the encoding overhead is > 2n/(8*256)*100%, where n is the number of critical characters. I believe it will be worse than that because you will have to re-encode the encoding bit depending on the value of the critical characters and your choice of values for the encoding bit. i.e., if you output a crtical character, then the tag bit + 7 more data bits goes into the next output byte. But if those 8 bits turn out to be a crtical character, then you have to tag that as well, etc. > For the pathological worst case the overhead is 1/8 = 12.5%. It's actually 1/7 or 14.3% isn't it? Because worst case, you could end up having to add a tag bit to every output byte so you add one bit of output overhead to every 7 input bits. > I have done some tests with n=3 (i.e. '\0', '\n', '\r') on a variety > of file types (text, mpeg, mp3, jpg, gif, png, zip, gz, ...) and have > never reached an overhead bigger than that of an uniform distribution > (0.293%). Interesting. But NNTP still requies CR LF to be added every so often, and you either must include dot in your crtical char list or do the dot escaping for NNTP, and TCP/IP adds a lot more overhead on top of that, so is there really any point in using anything more complex than yEnc when we already have a total encoding overhead which is much higher from all these other things? As a formal yEnc replacement, I think all that bit shifting is more complex than it needs to be to get the overhead low enough. I wonder if there is a simple byte oriented encoding system that could reach such low ovehead numbers without having to play bit shifting games? I wonder if there's a way to reach the same -- Curt Welch http://CurtWelch.Com/ curt@kcwc.com Webmaster for http://NewsReader.Com/
Re: Idea for a efficient quasi 8bit CTE (qp-special-lite)
Author: Lykas
Date: Fri, 15 Nov 2002 11:10
Date: Fri, 15 Nov 2002 11:10
61 lines
4000 bytes
4000 bytes
curt@kcwc.com (Curt Welch) wrote in message news:<20021114123345.397$aD@newsreader.com>... > lykas@gmx.ch (Lykas) wrote: > > For a uniformaly distributed input stream the encoding overhead is > > 2n/(8*256)*100%, where n is the number of critical characters. > > I believe it will be worse than that because you will have to re-encode > the encoding bit depending on the value of the critical characters > and your choice of values for the encoding bit. > > i.e., if you output a crtical character, then the tag bit + 7 more > data bits goes into the next output byte. But if those 8 bits turn > out to be a crtical character, then you have to tag that as well, etc. > You are right! The replacement characters have to be choosen so that changing the tag bit dosen't turn them into critical characters. So it would constrain the choice of replacement characters a bit. (In my implementation I chose replacement character = critical character xor 128, which is ok for the three critical characters I used for the tests.) > > For the pathological worst case the overhead is 1/8 = 12.5%. > > It's actually 1/7 or 14.3% isn't it? Because worst case, you could end up > having to add a tag bit to every output byte so you add one bit of output > overhead to every 7 input bits. > No, you add 1 bit to every 8 input bits. The 8 bits of the critical character become 8 bits of the non critical replacement character plus one tag bit. > > I have done some tests with n=3 (i.e. '\0', '\n', '\r') on a variety > > of file types (text, mpeg, mp3, jpg, gif, png, zip, gz, ...) and have > > never reached an overhead bigger than that of an uniform distribution > > (0.293%). > > Interesting. But NNTP still requies CR LF to be added every so often, and > you either must include dot in your crtical char list or do the dot > escaping for NNTP, and TCP/IP adds a lot more overhead on top of that, so > is there really any point in using anything more complex than yEnc when we > already have a total encoding overhead which is much higher from all these > other things? > With a line length of 998 + CR LF you add ~0.2% overhead and you are still below 0.5%. You can use CR or LF for padding to move the dot or critical character strings away from the begining of a line. > As a formal yEnc replacement, I think all that bit shifting is more complex > than it needs to be to get the overhead low enough. > It is more the "add 42" I don't like in yEnc than the overhead. Replacing that with "xor byte_counter (modulo 256)" would be nice. > I wonder if there is a simple byte oriented encoding system that could > reach such low ovehead numbers without having to play bit shifting games? > > I wonder if there's a way to reach the same You can accumulate the tag bits to a byte and output them after every seven critical/replacement characters. This is a little less efficient and require seeking in the input stream for either encoding or decoding (and of course still requires bit shifting).
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads