summaryrefslogtreecommitdiff
path: root/libavcodec/get_bits.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-09-30 02:39:55 +0200
committerJustin Ruggles <justin.ruggles@gmail.com>2012-12-07 16:15:02 -0500
commit41540b36a19d326e778268e910aff4217b20eb97 (patch)
treec97113430eb08fcc5ea32477428f7de84ebcd1cf /libavcodec/get_bits.h
parentb57c1da81e4f9d46af6ad9f69e6e2255d5b8aaff (diff)
bitstream: add get_bits64() to support reading more than 32 bits at once
Also remove a duplicate function in the MPEG-TS demuxer. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
Diffstat (limited to 'libavcodec/get_bits.h')
-rw-r--r--libavcodec/get_bits.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index f91441c120..c56a2c2d10 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -313,6 +313,24 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n)
}
}
+/*
+ * Read 0-64 bits.
+ */
+static inline uint64_t get_bits64(GetBitContext *s, int n)
+{
+ if (n <= 32) {
+ return get_bits_long(s, n);
+ } else {
+#ifdef BITSTREAM_READER_LE
+ uint64_t ret = get_bits_long(s, 32);
+ return ret | (uint64_t)get_bits_long(s, n - 32) << 32;
+#else
+ uint64_t ret = (uint64_t)get_bits_long(s, n - 32) << 32;
+ return ret | get_bits_long(s, 32);
+#endif
+ }
+}
+
/**
* Read 0-32 bits as a signed integer.
*/