X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bitsource.h;h=60744b32e12bdc7809f8b0d7cf47d3271a8b8295;hb=a733460846675aab7117c5cf1213d1b62785793d;hp=bb3a6d246e62016665e5560ac048397b15f7f8e9;hpb=ddc3c24c837f081787825d128675eca628d0e91c;p=fjl diff --git a/bitsource.h b/bitsource.h index bb3a6d2..60744b3 100644 --- a/bitsource.h +++ b/bitsource.h @@ -2,6 +2,7 @@ #define _BITSOURCE_H 1 #include +#include #include #include #include @@ -37,12 +38,19 @@ struct bit_source { uint8_t* byte_read_ptr; unsigned bytes_available; + // Some clients will purposedly read a bit ahead of the stream, causing + // problems at EOF. Thus, the client is allowed to request that we pad + // the end stream with a few bytes after the source reports EOF. + int padding_bytes_available; + // Data source. input_func_t* input_func; void* userdata; + bool source_eof; }; -void init_bit_source(struct bit_source* source, input_func_t* input_func, void* userdata); +void init_bit_source(struct bit_source* source, input_func_t* input_func, + unsigned padding_bytes, void* userdata); // Internal function. Do not use. void possibly_refill_slow_path(struct bit_source* source, unsigned num_bits);