---
 libavcodec/bitstream.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
index 996e32e..1196a55 100644
--- a/libavcodec/bitstream.h
+++ b/libavcodec/bitstream.h
@@ -71,6 +71,15 @@ static inline void refill_32(BitstreamContext *bc)
     bc->bits_left += 32;
 }
 
+/* Make sure that the cache contains at least n bits */
+static inline void bitstream_prefetch(BitstreamContext *bc, unsigned n)
+{
+    refill_32(bc);
+
+    if (bc->bits_left < n)
+        refill_32(bc);
+}
+
 /* Initialize BitstreamContext. Input buffer must have an additional zero
  * padding of AV_INPUT_BUFFER_PADDING_SIZE bytes at the end. */
 static inline int bitstream_init(BitstreamContext *bc, const uint8_t *buffer,
@@ -141,6 +150,12 @@ static inline uint64_t get_val(BitstreamContext *bc, 
unsigned n)
     return ret;
 }
 
+/* Return n bits from the cache. n has to be in the 1-32 range. */
+static inline unsigned bitstream_read_cache(BitstreamContext *bc, unsigned n)
+{
+    return get_val(bc, n);
+}
+
 /* Return one bit from the buffer. */
 static inline unsigned bitstream_read_bit(BitstreamContext *bc)
 {
-- 
2.6.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to