Skip to content
Snippets Groups Projects
Commit d84fa9fd authored by Gregory Maxwell's avatar Gregory Maxwell
Browse files

Fixes a bug in ec_enc_done when no range coded data was coded and adds test...

Fixes a bug in ec_enc_done when no range coded data was coded and adds test cases to test_unit_entropy.
parent aecf2d3e
No related branches found
No related tags found
No related merge requests found
...@@ -287,8 +287,8 @@ void ec_enc_done(ec_enc *_this){ ...@@ -287,8 +287,8 @@ void ec_enc_done(ec_enc *_this){
window&=(1<<l)-1; window&=(1<<l)-1;
_this->error=-1; _this->error=-1;
} }
_this->buf[_this->storage-_this->end_offs-1]|=(unsigned char)window;
} }
_this->buf[_this->storage-_this->end_offs-1]|=(unsigned char)window;
} }
} }
} }
...@@ -326,6 +326,25 @@ int main(int _argc,char **_argv){ ...@@ -326,6 +326,25 @@ int main(int _argc,char **_argv){
fprintf(stderr,"Got %d when expecting 63 for patch_initial_bits",ptr[0]); fprintf(stderr,"Got %d when expecting 63 for patch_initial_bits",ptr[0]);
ret=-1; ret=-1;
} }
ec_enc_init(&enc,ptr,2);
ec_enc_bit_logp(&enc,0,2);
for(i=0;i<48;i++){
ec_enc_bits(&enc,0,1);
}
ec_enc_done(&enc);
if(!enc.error){
fprintf(stderr,"Raw bits overfill didn't fail when it should have");
ret=-1;
}
ec_enc_init(&enc,ptr,2);
for(i=0;i<17;i++){
ec_enc_bits(&enc,0,1);
}
ec_enc_done(&enc);
if(!enc.error){
fprintf(stderr,"17 raw bits encoded in two bytes");
ret=-1;
}
free(ptr); free(ptr);
return ret; return ret;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment