Total program runtime is reduced between 10--30% through performance-oriented changes to bitops/aricoder and the dependent code in packjpg. In addition, verifiable correctness is improved where it is possible to do so in a performance-neutral way.
Bitops Highlights:
Memory reallocation is changed from additive to multiplicative (e.g., when bytewriter exceeds its current internal capacity, instead of adding a flat amount of memory, the capacity is now doubled).
Implementation and use of read_byte/write_byte for single-byte IO.
Use of setvbuf for a larger file io buffer (the default seems to be 512 bytes, at least for MSVC++).
Use of memset/memcopy (through std::fill and std::copy) where possible instead of simple for loops.
Some public fields in the bitops classes were made private and given simple getter methods to improve the encapsulation of bitops. Some basic bounds checks are also added to a few of the bitops classes to improve correctness on invalid inputs (e.g., requesting a negative number of bytes from a reader).
Aricoder Highlights:
Removed dead code paths (e.g., non-above symbol paths in exclude_symbols and table.lesser).
Better memory allocation (ref bitops).
Cache locality exploited in decode/encode (local copies of fields are used to improve performance).
Use of memset/memcopy (through std::fill and std::copy) where possible.
Use of template functions (e.g., he various shift_model functions are rolled into a single function using a variadic template).
Some functions in model_s and model_b were moved to table_s and table, respectively. Since tables are always rescaled by rightshifting by 1 in packjpg (and all pack* in general, I believe), I changed the rescale_table signature to () from (int scale_factor) to reflect this.
Visual Studio Compilation Fix
iostream::open_stream is changed to accomodate Visual Studio 2015; in particular, the functions for selecting the binary mode for streams are fixed.
Total program runtime is reduced between 10--30% through performance-oriented changes to bitops/aricoder and the dependent code in packjpg. In addition, verifiable correctness is improved where it is possible to do so in a performance-neutral way.
Bitops Highlights:
Some public fields in the bitops classes were made private and given simple getter methods to improve the encapsulation of bitops. Some basic bounds checks are also added to a few of the bitops classes to improve correctness on invalid inputs (e.g., requesting a negative number of bytes from a reader).
Aricoder Highlights:
Some functions in model_s and model_b were moved to table_s and table, respectively. Since tables are always rescaled by rightshifting by 1 in packjpg (and all pack* in general, I believe), I changed the rescale_table signature to () from (int scale_factor) to reflect this.
Visual Studio Compilation Fix
iostream::open_stream is changed to accomodate Visual Studio 2015; in particular, the functions for selecting the binary mode for streams are fixed.