]> git.sesse.net Git - fjl/blobdiff - bitsource.h
Add optional padding data at the end to the bit source (is that the right place?...
[fjl] / bitsource.h
index bb3a6d246e62016665e5560ac048397b15f7f8e9..ae29b4c4a2200abce210242a541be2c289ea8163 100644 (file)
@@ -37,12 +37,18 @@ struct bit_source {
        uint8_t* byte_read_ptr;
        unsigned bytes_available;
 
        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;
 };
 
        // Data source.
        input_func_t* input_func;
        void* userdata;
 };
 
-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);
 
 // Internal function. Do not use.
 void possibly_refill_slow_path(struct bit_source* source, unsigned num_bits);