ref: a2fd116d16b6fbb8b9d21ac4f969edc8f6b6087e
parent: bab4fb19e2a9bc9d970e0b17c1c35ba3e2b3aa11
author: Timothy B. Terriberry <[email protected]>
date: Thu Jan 24 17:28:58 EST 2008
Remove end-byte handling to allow arbitrary padding with zeros for CBR. From d28a530115ee7c739f12a6afb7e233cd29f64869 Mon Sep 17 00:00:00 2001 From: Timothy B. Terriberry <[email protected]> Date: Thu, 24 Jan 2008 21:56:48 -0500 Subject: [PATCH] Remove end-byte handling to allow arbitrary padding with zeros for CBR.
--- a/libentcode/mfrngdec.c
+++ b/libentcode/mfrngdec.c
@@ -137,22 +137,7 @@
int ret;
ret=ec_byte_read1(_this->buf);
if(ret<0){
- unsigned char *buf;
- long i;
- i=ec_byte_bytes(_this->buf);
- buf=ec_byte_get_buffer(_this->buf);
- /*Breaking abstraction: don't do this at home, kids.*/
- if(_this->buf->storage==i&&i>0){
- unsigned char *buf;
- buf=ec_byte_get_buffer(_this->buf);
- /*If we end in a string of 0 or more EC_FOF_RSV1 bytes preceded by a
- zero, return an extra EC_FOF_RSV1 byte.*/
- do i--;
- while(i>0&&buf[i]==EC_FOF_RSV1);
- if(!buf[i])ret=EC_FOF_RSV1;
- else ret=0;
- }
- else ret=0;
+ ret=0;
/*Needed to make sure the above conditional only triggers once, and to keep
oc_dec_tell() operating correctly.*/
ec_byte_adv1(_this->buf);
--- a/libentcode/mfrngenc.c
+++ b/libentcode/mfrngenc.c
@@ -167,28 +167,9 @@
end=end<<EC_SYM_BITS&EC_CODE_TOP-1;
}
}
- /*If we have a buffered byte...*/
+ /*If we have a buffered byte flush it into the output buffer.*/
if(_this->rem>=0){
- unsigned char *buf;
- long i;
- /*Flush it into the output buffer.*/
ec_enc_carry_out(_this,0);
_this->rem=-1;
- /*We may be able to drop some redundant bytes from the end.*/
- buf=ec_byte_get_buffer(_this->buf);
- i=ec_byte_bytes(_this->buf);
- /*Strip trailing zeros.*/
- do i--;
- while(i>0&&!buf[i]);
- /*Strip one trailing EC_FOF_RSV1 byte if the buffer ends in a string of
- consecutive EC_FOF_RSV1 bytes preceded by one (or more) zeros.*/
- if(i>0&&buf[i]==EC_FOF_RSV1){
- long j;
- j=i;
- do j--;
- while(j>0&&buf[j]==EC_FOF_RSV1);
- if(!buf[j])i--;
- }
- ec_byte_writetrunc(_this->buf,i+1);
}
}
--- a/libentcode/rangedec.c
+++ b/libentcode/rangedec.c
@@ -121,22 +121,7 @@
int ret;
ret=ec_byte_read1(_this->buf);
if(ret<0){
- unsigned char *buf;
- long i;
- i=ec_byte_bytes(_this->buf);
- buf=ec_byte_get_buffer(_this->buf);
- /*Breaking abstraction: don't do this at home, kids.*/
- if(_this->buf->storage==i&&i>0){
- unsigned char *buf;
- buf=ec_byte_get_buffer(_this->buf);
- /*If we end in a string of 0 or more EC_FOF_RSV1 bytes preceded by a
- zero, return an extra EC_FOF_RSV1 byte.*/
- do i--;
- while(i>0&&buf[i]==EC_FOF_RSV1);
- if(!buf[i])ret=EC_FOF_RSV1;
- else ret=0;
- }
- else ret=0;
+ ret=0;
/*Needed to make sure the above conditional only triggers once, and to keep
oc_dec_tell() operating correctly.*/
ec_byte_adv1(_this->buf);
--- a/libentcode/rangeenc.c
+++ b/libentcode/rangeenc.c
@@ -137,28 +137,9 @@
end=end<<EC_SYM_BITS&EC_CODE_TOP-1;
}
}
- /*If we have a buffered byte...*/
+ /*If we have a buffered byte flush it into the output buffer.*/
if(_this->rem>=0){
- unsigned char *buf;
- long i;
- /*Flush it into the output buffer.*/
ec_enc_carry_out(_this,0);
_this->rem=-1;
- /*We may be able to drop some redundant bytes from the end.*/
- buf=ec_byte_get_buffer(_this->buf);
- i=ec_byte_bytes(_this->buf);
- /*Strip trailing zeros.*/
- do i--;
- while(i>0&&!buf[i]);
- /*Strip one trailing EC_FOF_RSV1 byte if the buffer ends in a string of
- consecutive EC_FOF_RSV1 bytes preceded by one (or more) zeros.*/
- if(i>0&&buf[i]==EC_FOF_RSV1){
- long j;
- j=i;
- do j--;
- while(j>0&&buf[j]==EC_FOF_RSV1);
- if(!buf[j])i--;
- }
- ec_byte_writetrunc(_this->buf,i+1);
}
}