[FFmpeg-cvslog] avcodec/get_bits: actually make cached reader correctly disabled

James Almer git at videolan.org
Thu Aug 30 23:58:47 EEST 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Aug 30 22:36:55 2018 +0200| [9305bdc68f0976e0c5870f0d0557a45fe13bb0f6] | committer: Paul B Mahol

avcodec/get_bits: actually make cached reader correctly disabled

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9305bdc68f0976e0c5870f0d0557a45fe13bb0f6
---

 libavcodec/get_bits.h | 40 ++++++++++++++++++++++------------------
 libavcodec/golomb.h   | 14 +++++++-------
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 58ebb64656..26a5b3e54f 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -54,9 +54,13 @@
 #define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
 #endif
 
+#ifndef CACHED_BITSTREAM_READER
+#define CACHED_BITSTREAM_READER 0
+#endif
+
 typedef struct GetBitContext {
     const uint8_t *buffer, *buffer_end;
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     uint64_t cache;
     unsigned bits_left;
 #endif
@@ -116,7 +120,7 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
  * For examples see get_bits, show_bits, skip_bits, get_vlc.
  */
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
 #   define MIN_CACHE_BITS 64
 #elif defined LONG_BITSTREAM_READER
 #   define MIN_CACHE_BITS 32
@@ -124,7 +128,7 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
 #   define MIN_CACHE_BITS 25
 #endif
 
-#ifndef CACHED_BITSTREAM_READER
+#if !CACHED_BITSTREAM_READER
 
 #define OPEN_READER_NOSIZE(name, gb)            \
     unsigned int name ## _index = (gb)->index;  \
@@ -214,14 +218,14 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
 
 static inline int get_bits_count(const GetBitContext *s)
 {
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     return s->index - s->bits_left;
 #else
     return s->index;
 #endif
 }
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
 static inline void refill_32(GetBitContext *s)
 {
 #if !UNCHECKED_BITSTREAM_READER
@@ -288,7 +292,7 @@ static inline unsigned show_val(const GetBitContext *s, unsigned n)
  */
 static inline void skip_bits_long(GetBitContext *s, int n)
 {
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     skip_bits(s, n);
 #else
 #if UNCHECKED_BITSTREAM_READER
@@ -299,7 +303,7 @@ static inline void skip_bits_long(GetBitContext *s, int n)
 #endif
 }
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
 static inline void skip_remaining(GetBitContext *s, unsigned n)
 {
 #ifdef BITSTREAM_READER_LE
@@ -318,7 +322,7 @@ static inline void skip_remaining(GetBitContext *s, unsigned n)
  */
 static inline int get_xbits(GetBitContext *s, int n)
 {
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     int32_t cache = show_bits(s, 32);
     int sign = ~cache >> 31;
     skip_remaining(s, n);
@@ -338,7 +342,7 @@ static inline int get_xbits(GetBitContext *s, int n)
 #endif
 }
 
-#ifndef CACHED_BITSTREAM_READER
+#if !CACHED_BITSTREAM_READER
 static inline int get_xbits_le(GetBitContext *s, int n)
 {
     register int sign;
@@ -357,7 +361,7 @@ static inline int get_xbits_le(GetBitContext *s, int n)
 static inline int get_sbits(GetBitContext *s, int n)
 {
     register int tmp;
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     av_assert2(n>0 && n<=25);
     tmp = sign_extend(get_bits(s, n), n);
 #else
@@ -377,7 +381,7 @@ static inline int get_sbits(GetBitContext *s, int n)
 static inline unsigned int get_bits(GetBitContext *s, int n)
 {
     register int tmp;
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
 
     av_assert2(n>0 && n<=32);
     if (n > s->bits_left) {
@@ -412,7 +416,7 @@ static av_always_inline int get_bitsz(GetBitContext *s, int n)
 
 static inline unsigned int get_bits_le(GetBitContext *s, int n)
 {
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     av_assert2(n>0 && n<=32);
     if (n > s->bits_left) {
         refill_32(s);
@@ -439,7 +443,7 @@ static inline unsigned int get_bits_le(GetBitContext *s, int n)
 static inline unsigned int show_bits(GetBitContext *s, int n)
 {
     register int tmp;
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     if (n > s->bits_left)
         refill_32(s);
 
@@ -455,7 +459,7 @@ static inline unsigned int show_bits(GetBitContext *s, int n)
 
 static inline void skip_bits(GetBitContext *s, int n)
 {
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     if (n < s->bits_left)
         skip_remaining(s, n);
     else {
@@ -482,7 +486,7 @@ static inline void skip_bits(GetBitContext *s, int n)
 
 static inline unsigned int get_bits1(GetBitContext *s)
 {
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     if (!s->bits_left)
         refill_64(s);
 
@@ -529,7 +533,7 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n)
     av_assert2(n>=0 && n<=32);
     if (!n) {
         return 0;
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     }
     return get_bits(s, n);
 #else
@@ -628,7 +632,7 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
     s->buffer_end         = buffer + buffer_size;
     s->index              = 0;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     refill_64(s);
 #endif
 
@@ -758,7 +762,7 @@ static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits,
 static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
                                      int bits, int max_depth)
 {
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     int nb_bits;
     unsigned idx = show_bits(s, bits);
     int code = table[idx][0];
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index e66675b292..5c25883626 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -54,7 +54,7 @@ static inline int get_ue_golomb(GetBitContext *gb)
 {
     unsigned int buf;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     buf = show_bits_long(gb, 32);
 
     if (buf >= (1 << 27)) {
@@ -119,7 +119,7 @@ static inline int get_ue_golomb_31(GetBitContext *gb)
 {
     unsigned int buf;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     buf = show_bits_long(gb, 32);
 
     buf >>= 32 - 9;
@@ -142,7 +142,7 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb)
 {
     uint32_t buf;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     buf = show_bits_long(gb, 32);
 
     if (buf & 0xAA800000) {
@@ -238,7 +238,7 @@ static inline int get_se_golomb(GetBitContext *gb)
 {
     unsigned int buf;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     buf = show_bits_long(gb, 32);
 
     if (buf >= (1 << 27)) {
@@ -300,7 +300,7 @@ static inline int get_interleaved_se_golomb(GetBitContext *gb)
 {
     unsigned int buf;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     buf = show_bits_long(gb, 32);
 
     if (buf & 0xAA800000) {
@@ -375,7 +375,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
     unsigned int buf;
     int log;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     buf = show_bits_long(gb, 32);
 
     log = av_log2(buf);
@@ -429,7 +429,7 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
     unsigned int buf;
     int log;
 
-#ifdef CACHED_BITSTREAM_READER
+#if CACHED_BITSTREAM_READER
     buf = show_bits_long(gb, 32);
 
     log = av_log2(buf);



More information about the ffmpeg-cvslog mailing list