diff options
author | Diego Biurrun <diego@biurrun.de> | 2017-01-30 20:24:38 +0100 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2017-01-31 17:46:19 +0100 |
commit | d4c2103bd30ff6ceea70c3696ae88a7d2ea72493 (patch) | |
tree | db4896f7bdef00b43d6a0d69678c9ae8cf0d46f9 /libavcodec | |
parent | ab87af41636b081dd3562423999351b5444fa09e (diff) | |
download | ffmpeg-d4c2103bd30ff6ceea70c3696ae88a7d2ea72493.tar.gz |
golomb: Convert to the new bitstream reader
Diffstat (limited to 'libavcodec')
34 files changed, 692 insertions, 159 deletions
diff --git a/libavcodec/aic.c b/libavcodec/aic.c index 2c9b6f8098..405ebf12d5 100644 --- a/libavcodec/aic.c +++ b/libavcodec/aic.c @@ -26,7 +26,7 @@ #include "bytestream.h" #include "internal.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "idctdsp.h" #include "thread.h" #include "unary_legacy.h" diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index cf66629ffd..bf1a59a6f0 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "h264chroma.h" #include "idctdsp.h" #include "internal.h" diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 1c4f276373..5a28fc04ed 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "cavs.h" #include "internal.h" #include "mpeg12data.h" diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c index 142af20579..cce9439d44 100644 --- a/libavcodec/dirac.c +++ b/libavcodec/dirac.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "dirac.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "internal.h" #include "mpeg12data.h" diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index d3169ec7c5..2ebd6864a1 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -31,12 +31,13 @@ #include "libavutil/opt.h" #include "libavutil/imgutils.h" #include "libavutil/timer.h" + #include "avcodec.h" +#include "golomb_legacy.h" #include "internal.h" #include "get_bits.h" #include "put_bits.h" #include "rangecoder.h" -#include "golomb.h" #include "mathops.h" #include "ffv1.h" diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 0eeccfffb4..adf70d8a6b 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -33,10 +33,10 @@ #include "libavutil/imgutils.h" #include "avcodec.h" +#include "golomb_legacy.h" #include "internal.h" #include "put_bits.h" #include "rangecoder.h" -#include "golomb.h" #include "mathops.h" #include "ffv1.h" diff --git a/libavcodec/fic.c b/libavcodec/fic.c index b1286ebe65..1804104916 100644 --- a/libavcodec/fic.c +++ b/libavcodec/fic.c @@ -22,10 +22,11 @@ */ #include "libavutil/common.h" + #include "avcodec.h" +#include "golomb_legacy.h" #include "internal.h" #include "get_bits.h" -#include "golomb.h" typedef struct FICThreadContext { DECLARE_ALIGNED(16, int16_t, block)[64]; diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 7af71f3c0c..78be2adab3 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -37,7 +37,7 @@ #include "internal.h" #include "get_bits.h" #include "bytestream.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "flac.h" #include "flacdata.h" #include "flacdsp.h" diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 67f899f712..0c1e6b7673 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "bswapdsp.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "internal.h" #include "lpc.h" #include "flac.h" diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 9fafbcda70..648f9243fc 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -32,7 +32,7 @@ #include <stdint.h> -#include "get_bits.h" +#include "bitstream.h" #include "put_bits.h" #define INVALID_VLC 0x80000000 @@ -50,26 +50,22 @@ extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256]; /** * read unsigned exp golomb code. */ -static inline int get_ue_golomb(GetBitContext *gb) +static inline int get_ue_golomb(BitstreamContext *bc) { unsigned int buf; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); + buf = bitstream_peek(bc, 32); if (buf >= (1 << 27)) { buf >>= 32 - 9; - LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]); - CLOSE_READER(re, gb); + bitstream_skip(bc, ff_golomb_vlc_len[buf]); return ff_ue_golomb_vlc_code[buf]; } else { int log = 2 * av_log2(buf) - 31; buf >>= log; buf--; - LAST_SKIP_BITS(re, gb, 32 - log); - CLOSE_READER(re, gb); + bitstream_skip(bc, 32 - log); return buf; } @@ -78,48 +74,42 @@ static inline int get_ue_golomb(GetBitContext *gb) /** * Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1. */ -static inline unsigned get_ue_golomb_long(GetBitContext *gb) +static inline unsigned get_ue_golomb_long(BitstreamContext *bc) { unsigned buf, log; - buf = show_bits_long(gb, 32); + buf = bitstream_peek(bc, 32); log = 31 - av_log2(buf); - skip_bits_long(gb, log); + bitstream_skip(bc, log); - return get_bits_long(gb, log + 1) - 1; + return bitstream_read(bc, log + 1) - 1; } /** * read unsigned exp golomb code, constraint to a max of 31. * the return value is undefined if the stored value exceeds 31. */ -static inline int get_ue_golomb_31(GetBitContext *gb) +static inline int get_ue_golomb_31(BitstreamContext *bc) { unsigned int buf; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); + buf = bitstream_peek(bc, 32); buf >>= 32 - 9; - LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]); - CLOSE_READER(re, gb); + bitstream_skip(bc, ff_golomb_vlc_len[buf]); return ff_ue_golomb_vlc_code[buf]; } -static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) +static inline unsigned get_interleaved_ue_golomb(BitstreamContext *bc) { uint32_t buf; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); + buf = bitstream_peek(bc, 32); if (buf & 0xAA800000) { buf >>= 32 - 8; - LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]); - CLOSE_READER(re, gb); + bitstream_skip(bc, ff_interleaved_golomb_vlc_len[buf]); return ff_interleaved_ue_golomb_vlc_code[buf]; } else { @@ -127,8 +117,7 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) do { buf >>= 32 - 8; - LAST_SKIP_BITS(re, gb, - FFMIN(ff_interleaved_golomb_vlc_len[buf], 8)); + bitstream_skip(bc, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8)); if (ff_interleaved_golomb_vlc_len[buf] != 9) { ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1; @@ -136,11 +125,9 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) break; } ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf]; - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); - } while (BITS_AVAILABLE(re, gb)); + buf = bitstream_peek(bc, 32); + } while (bitstream_bits_left(bc) > 0); - CLOSE_READER(re, gb); return ret - 1; } } @@ -148,54 +135,50 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) /** * read unsigned truncated exp golomb code. */ -static inline int get_te0_golomb(GetBitContext *gb, int range) +static inline int get_te0_golomb(BitstreamContext *bc, int range) { assert(range >= 1); if (range == 1) return 0; else if (range == 2) - return get_bits1(gb) ^ 1; + return bitstream_read_bit(bc) ^ 1; else - return get_ue_golomb(gb); + return get_ue_golomb(bc); } /** * read unsigned truncated exp golomb code. */ -static inline int get_te_golomb(GetBitContext *gb, int range) +static inline int get_te_golomb(BitstreamContext *bc, int range) { assert(range >= 1); if (range == 2) - return get_bits1(gb) ^ 1; + return bitstream_read_bit(bc) ^ 1; else - return get_ue_golomb(gb); + return get_ue_golomb(bc); } /** * read signed exp golomb code. */ -static inline int get_se_golomb(GetBitContext *gb) +static inline int get_se_golomb(BitstreamContext *bc) { unsigned int buf; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); + buf = bitstream_peek(bc, 32); if (buf >= (1 << 27)) { buf >>= 32 - 9; - LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]); - CLOSE_READER(re, gb); + bitstream_skip(bc, ff_golomb_vlc_len[buf]); return ff_se_golomb_vlc_code[buf]; } else { int log = 2 * av_log2(buf) - 31; buf >>= log; - LAST_SKIP_BITS(re, gb, 32 - log); - CLOSE_READER(re, gb); + bitstream_skip(bc, 32 - log); if (buf & 1) buf = -(buf >> 1); @@ -206,9 +189,9 @@ static inline int get_se_golomb(GetBitContext *gb) } } -static inline int get_se_golomb_long(GetBitContext *gb) +static inline int get_se_golomb_long(BitstreamContext *bc) { - unsigned int buf = get_ue_golomb_long(gb); + unsigned int buf = get_ue_golomb_long(bc); if (buf & 1) buf = (buf + 1) >> 1; @@ -218,25 +201,21 @@ static inline int get_se_golomb_long(GetBitContext *gb) return buf; } -static inline int get_interleaved_se_golomb(GetBitContext *gb) +static inline int get_interleaved_se_golomb(BitstreamContext *bc) { unsigned int buf; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); + buf = bitstream_peek(bc, 32); if (buf & 0xAA800000) { buf >>= 32 - 8; - LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]); - CLOSE_READER(re, gb); + bitstream_skip(bc, ff_interleaved_golomb_vlc_len[buf]); return ff_interleaved_se_golomb_vlc_code[buf]; } else { int log; - LAST_SKIP_BITS(re, gb, 8); - UPDATE_CACHE(re, gb); - buf |= 1 | (GET_CACHE(re, gb) >> 8); + bitstream_skip(bc, 8); + buf |= 1 | bitstream_peek(bc, 24); if ((buf & 0xAAAAAAAA) == 0) return INVALID_VLC; @@ -244,25 +223,20 @@ static inline int get_interleaved_se_golomb(GetBitContext *gb) for (log = 31; (buf & 0x80000000) == 0; log--) buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30); - LAST_SKIP_BITS(re, gb, 63 - 2 * log - 8); - CLOSE_READER(re, gb); + bitstream_skip(bc, 63 - 2 * log - 8); return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1; } } -static inline int dirac_get_se_golomb(GetBitContext *gb) +static inline int dirac_get_se_golomb(BitstreamContext *bc) { - uint32_t ret = get_interleaved_ue_golomb(gb); + uint32_t ret = get_interleaved_ue_golomb(bc); if (ret) { uint32_t buf; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = SHOW_SBITS(re, gb, 1); - LAST_SKIP_BITS(re, gb, 1); + buf = bitstream_read_signed(bc, 1); ret = (ret ^ buf) - buf; - CLOSE_READER(re, gb); } return ret; @@ -271,33 +245,25 @@ static inline int dirac_get_se_golomb(GetBitContext *gb) /** * read unsigned golomb rice code (ffv1). */ -static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, +static inline int get_ur_golomb(BitstreamContext *bc, int k, int limit, int esc_len) { unsigned int buf; int log; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); + buf = bitstream_peek(bc, 32); log = av_log2(buf); if (log > 31 - limit) { buf >>= log - k; buf += (30 - log) << k; - LAST_SKIP_BITS(re, gb, 32 + k - log); - CLOSE_READER(re, gb); + bitstream_skip(bc, 32 + k - log); return buf; } else { - LAST_SKIP_BITS(re, gb, limit); - UPDATE_CACHE(re, gb); - - buf = SHOW_UBITS(re, gb, esc_len); - - LAST_SKIP_BITS(re, gb, esc_len); - CLOSE_READER(re, gb); + bitstream_skip(bc, limit); + buf = bitstream_read(bc, esc_len); return buf + limit - 1; } @@ -306,48 +272,38 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, /** * read unsigned golomb rice code (jpegls). */ -static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, +static inline int get_ur_golomb_jpegls(BitstreamContext *bc, int k, int limit, int esc_len) { unsigned int buf; int log; - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf = GET_CACHE(re, gb); + buf = bitstream_peek(bc, 32); log = av_log2(buf); - if (log - k >= 32 - MIN_CACHE_BITS + (MIN_CACHE_BITS == 32) && - 32 - log < limit) { + if (log - k >= 1 && 32 - log < limit) { buf >>= log - k; buf += (30 - log) << k; - LAST_SKIP_BITS(re, gb, 32 + k - log); - CLOSE_READER(re, gb); + bitstream_skip(bc, 32 + k - log); return buf; } else { int i; - for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0 && BITS_AVAILABLE(re, gb); i++) { - LAST_SKIP_BITS(re, gb, 1); - UPDATE_CACHE(re, gb); - } - SKIP_BITS(re, gb, 1); + for (i = 0; i < limit && bitstream_peek(bc, 1) == 0 && bitstream_bits_left(bc) > 0; i++) + bitstream_skip(bc, 1); + bitstream_skip(bc, 1); if (i < limit - 1) { if (k) { - buf = SHOW_UBITS(re, gb, k); - LAST_SKIP_BITS(re, gb, k); + buf = bitstream_read(bc, k); } else { buf = 0; } - CLOSE_READER(re, gb); return buf + (i << k); } else if (i == limit - 1) { - buf = SHOW_UBITS(re, gb, esc_len); - LAST_SKIP_BITS(re, gb, esc_len); - CLOSE_READER(re, gb); + buf = bitstream_read(bc, esc_len); return buf + 1; } else @@ -358,10 +314,10 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, /** * read signed golomb rice code (ffv1). */ -static inline int get_sr_golomb(GetBitContext *gb, int k, int limit, +static inline int get_sr_golomb(BitstreamContext *bc, int k, int limit, int esc_len) { - int v = get_ur_golomb(gb, k, limit, esc_len); + int v = get_ur_golomb(bc, k, limit, esc_len); v++; if (v & 1) @@ -375,27 +331,27 @@ static inline int get_sr_golomb(GetBitContext *gb, int k, int limit, /** * read signed golomb rice code (flac). */ -static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, +static inline int get_sr_golomb_flac(BitstreamContext *bc, int k, int limit, int esc_len) { - int v = get_ur_golomb_jpegls(gb, k, limit, esc_len); + int v = get_ur_golomb_jpegls(bc, k, limit, esc_len); return (v >> 1) ^ -(v & 1); } /** * read unsigned golomb rice code (shorten). */ -static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k) +static inline unsigned int get_ur_golomb_shorten(BitstreamContext *bc, int k) { - return get_ur_golomb_jpegls(gb, k, INT_MAX, 0); + return get_ur_golomb_jpegls(bc, k, INT_MAX, 0); } /** * read signed golomb rice code (shorten). */ -static inline int get_sr_golomb_shorten(GetBitContext *gb, int k) +static inline int get_sr_golomb_shorten(BitstreamContext *bc, int k) { - int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0); + int uvar = get_ur_golomb_jpegls(bc, k + 1, INT_MAX, 0); if (uvar & 1) return ~(uvar >> 1); else @@ -404,13 +360,13 @@ static inline int get_sr_golomb_shorten(GetBitContext *gb, int k) #ifdef TRACE -static inline int get_ue(GetBitContext *s, const char *file, const char *func, +static inline int get_ue(BitstreamContext *s, const char *file, const char *func, int line) { - int show = show_bits(s, 24); - int pos = get_bits_count(s); + int show = bitstream_peek(s, 24); + int pos = bitstream_tell(s); int i = get_ue_golomb(s); - int len = get_bits_count(s) - pos; + int len = bitstream_tell(s) - pos; int bits = show >> (24 - len); av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue @%5d in %s %s:%d\n", @@ -419,13 +375,13 @@ static inline int get_ue(GetBitContext *s, const char *file, const char *func, return i; } -static inline int get_se(GetBitContext *s, const char *file, const char *func, +static inline int get_se(BitstreamContext *s, const char *file, const char *func, int line) { - int show = show_bits(s, 24); - int pos = get_bits_count(s); + int show = bitstream_peek(s, 24); + int pos = bitstream_tell(s); int i = get_se_golomb(s); - int len = get_bits_count(s) - pos; + int len = bitstream_tell(s) - pos; int bits = show >> (24 - len); av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se @%5d in %s %s:%d\n", @@ -434,13 +390,13 @@ static inline int get_se(GetBitContext *s, const char *file, const char *func, return i; } -static inline int get_te(GetBitContext *s, int r, char *file, const char *func, +static inline int get_te(BitstreamContext *s, int r, char *file, const char *func, int line) { - int show = show_bits(s, 24); - int pos = get_bits_count(s); + int show = bitstream_peek(s, 24); + int pos = bitstream_tell(s); int i = get_te0_golomb(s, r); - int len = get_bits_count(s) - pos; + int len = bitstream_tell(s) - pos; int bits = show >> (24 - len); av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te @%5d in %s %s:%d\n", diff --git a/libavcodec/golomb_legacy.h b/libavcodec/golomb_legacy.h new file mode 100644 index 0000000000..9fafbcda70 --- /dev/null +++ b/libavcodec/golomb_legacy.h @@ -0,0 +1,573 @@ +/* + * exp golomb vlc stuff + * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> + * Copyright (c) 2004 Alex Beregszaszi + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief + * exp golomb vlc stuff + * @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi + */ + +#ifndef AVCODEC_GOLOMB_H +#define AVCODEC_GOLOMB_H + +#include <stdint.h> + +#include "get_bits.h" +#include "put_bits.h" + +#define INVALID_VLC 0x80000000 + +extern const uint8_t ff_golomb_vlc_len[512]; +extern const uint8_t ff_ue_golomb_vlc_code[512]; +extern const int8_t ff_se_golomb_vlc_code[512]; +extern const uint8_t ff_ue_golomb_len[256]; + +extern const uint8_t ff_interleaved_golomb_vlc_len[256]; +extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256]; +extern const int8_t ff_interleaved_se_golomb_vlc_code[256]; +extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256]; + +/** + * read unsigned exp golomb code. + */ +static inline int get_ue_golomb(GetBitContext *gb) +{ + unsigned int buf; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + + if (buf >= (1 << 27)) { + buf >>= 32 - 9; + LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]); + CLOSE_READER(re, gb); + + return ff_ue_golomb_vlc_code[buf]; + } else { + int log = 2 * av_log2(buf) - 31; + buf >>= log; + buf--; + LAST_SKIP_BITS(re, gb, 32 - log); + CLOSE_READER(re, gb); + + return buf; + } +} + +/** + * Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1. + */ +static inline unsigned get_ue_golomb_long(GetBitContext *gb) +{ + unsigned buf, log; + + buf = show_bits_long(gb, 32); + log = 31 - av_log2(buf); + skip_bits_long(gb, log); + + return get_bits_long(gb, log + 1) - 1; +} + +/** + * read unsigned exp golomb code, constraint to a max of 31. + * the return value is undefined if the stored value exceeds 31. + */ +static inline int get_ue_golomb_31(GetBitContext *gb) +{ + unsigned int buf; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + + buf >>= 32 - 9; + LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]); + CLOSE_READER(re, gb); + + return ff_ue_golomb_vlc_code[buf]; +} + +static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) +{ + uint32_t buf; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + + if (buf & 0xAA800000) { + buf >>= 32 - 8; + LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]); + CLOSE_READER(re, gb); + + return ff_interleaved_ue_golomb_vlc_code[buf]; + } else { + unsigned ret = 1; + + do { + buf >>= 32 - 8; + LAST_SKIP_BITS(re, gb, + FFMIN(ff_interleaved_golomb_vlc_len[buf], 8)); + + if (ff_interleaved_golomb_vlc_len[buf] != 9) { + ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1; + ret |= ff_interleaved_dirac_golomb_vlc_code[buf]; + break; + } + ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf]; + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + } while (BITS_AVAILABLE(re, gb)); + + CLOSE_READER(re, gb); + return ret - 1; + } +} + +/** + * read unsigned truncated exp golomb code. + */ +static inline int get_te0_golomb(GetBitContext *gb, int range) +{ + assert(range >= 1); + + if (range == 1) + return 0; + else if (range == 2) + return get_bits1(gb) ^ 1; + else + return get_ue_golomb(gb); +} + +/** + * read unsigned truncated exp golomb code. + */ +static inline int get_te_golomb(GetBitContext *gb, int range) +{ + assert(range >= 1); + + if (range == 2) + return get_bits1(gb) ^ 1; + else + return get_ue_golomb(gb); +} + +/** + * read signed exp golomb code. + */ +static inline int get_se_golomb(GetBitContext *gb) +{ + unsigned int buf; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + + if (buf >= (1 << 27)) { + buf >>= 32 - 9; + LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]); + CLOSE_READER(re, gb); + + return ff_se_golomb_vlc_code[buf]; + } else { + int log = 2 * av_log2(buf) - 31; + buf >>= log; + + LAST_SKIP_BITS(re, gb, 32 - log); + CLOSE_READER(re, gb); + + if (buf & 1) + buf = -(buf >> 1); + else + buf = (buf >> 1); + + return buf; + } +} + +static inline int get_se_golomb_long(GetBitContext *gb) +{ + unsigned int buf = get_ue_golomb_long(gb); + + if (buf & 1) + buf = (buf + 1) >> 1; + else + buf = -(buf >> 1); + + return buf; +} + +static inline int get_interleaved_se_golomb(GetBitContext *gb) +{ + unsigned int buf; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + + if (buf & 0xAA800000) { + buf >>= 32 - 8; + LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]); + CLOSE_READER(re, gb); + + return ff_interleaved_se_golomb_vlc_code[buf]; + } else { + int log; + LAST_SKIP_BITS(re, gb, 8); + UPDATE_CACHE(re, gb); + buf |= 1 | (GET_CACHE(re, gb) >> 8); + + if ((buf & 0xAAAAAAAA) == 0) + return INVALID_VLC; + + for (log = 31; (buf & 0x80000000) == 0; log--) + buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30); + + LAST_SKIP_BITS(re, gb, 63 - 2 * log - 8); + CLOSE_READER(re, gb); + + return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1; + } +} + +static inline int dirac_get_se_golomb(GetBitContext *gb) +{ + uint32_t ret = get_interleaved_ue_golomb(gb); + + if (ret) { + uint32_t buf; + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = SHOW_SBITS(re, gb, 1); + LAST_SKIP_BITS(re, gb, 1); + ret = (ret ^ buf) - buf; + CLOSE_READER(re, gb); + } + + return ret; +} + +/** + * read unsigned golomb rice code (ffv1). + */ +static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, + int esc_len) +{ + unsigned int buf; + int log; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + + log = av_log2(buf); + + if (log > 31 - limit) { + buf >>= log - k; + buf += (30 - log) << k; + LAST_SKIP_BITS(re, gb, 32 + k - log); + CLOSE_READER(re, gb); + + return buf; + } else { + LAST_SKIP_BITS(re, gb, limit); + UPDATE_CACHE(re, gb); + + buf = SHOW_UBITS(re, gb, esc_len); + + LAST_SKIP_BITS(re, gb, esc_len); + CLOSE_READER(re, gb); + + return buf + limit - 1; + } +} + +/** + * read unsigned golomb rice code (jpegls). + */ +static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, + int esc_len) +{ + unsigned int buf; + int log; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf = GET_CACHE(re, gb); + + log = av_log2(buf); + + if (log - k >= 32 - MIN_CACHE_BITS + (MIN_CACHE_BITS == 32) && + 32 - log < limit) { + buf >>= log - k; + buf += (30 - log) << k; + LAST_SKIP_BITS(re, gb, 32 + k - log); + CLOSE_READER(re, gb); + + return buf; + } else { + int i; + for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0 && BITS_AVAILABLE(re, gb); i++) { + LAST_SKIP_BITS(re, gb, 1); + UPDATE_CACHE(re, gb); + } + SKIP_BITS(re, gb, 1); + + if (i < limit - 1) { + if (k) { + buf = SHOW_UBITS(re, gb, k); + LAST_SKIP_BITS(re, gb, k); + } else { + buf = 0; + } + + CLOSE_READER(re, gb); + return buf + (i << k); + } else if (i == limit - 1) { + buf = SHOW_UBITS(re, gb, esc_len); + LAST_SKIP_BITS(re, gb, esc_len); + CLOSE_READER(re, gb); + + return buf + 1; + } else + return -1; + } +} + +/** + * read signed golomb rice code (ffv1). + */ +static inline int get_sr_golomb(GetBitContext *gb, int k, int limit, + int esc_len) +{ + int v = get_ur_golomb(gb, k, limit, esc_len); + + v++; + if (v & 1) + return v >> 1; + else + return -(v >> 1); + +// return (v>>1) ^ -(v&1); +} + +/** + * read signed golomb rice code (flac). + */ +static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, + int esc_len) +{ + int v = get_ur_golomb_jpegls(gb, k, limit, esc_len); + return (v >> 1) ^ -(v & 1); +} + +/** + * read unsigned golomb rice code (shorten). + */ +static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k) +{ + return get_ur_golomb_jpegls(gb, k, INT_MAX, 0); +} + +/** + * read signed golomb rice code (shorten). + */ +static inline int get_sr_golomb_shorten(GetBitContext *gb, int k) +{ + int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0); + if (uvar & 1) + return ~(uvar >> 1); + else + return uvar >> 1; +} + +#ifdef TRACE + +static inline int get_ue(GetBitContext *s, const char *file, const char *func, + int line) +{ + int show = show_bits(s, 24); + int pos = get_bits_count(s); + int i = get_ue_golomb(s); + int len = get_bits_count(s) - pos; + int bits = show >> (24 - len); + + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue @%5d in %s %s:%d\n", + bits, len, i, pos, file, func, line); + + return i; +} + +static inline int get_se(GetBitContext *s, const char *file, const char *func, + int line) +{ + int show = show_bits(s, 24); + int pos = get_bits_count(s); + int i = get_se_golomb(s); + int len = get_bits_count(s) - pos; + int bits = show >> (24 - len); + + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se @%5d in %s %s:%d\n", + bits, len, i, pos, file, func, line); + + return i; +} + +static inline int get_te(GetBitContext *s, int r, char *file, const char *func, + int line) +{ + int show = show_bits(s, 24); + int pos = get_bits_count(s); + int i = get_te0_golomb(s, r); + int len = get_bits_count(s) - pos; + int bits = show >> (24 - len); + + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te @%5d in %s %s:%d\n", + bits, len, i, pos, file, func, line); + + return i; +} + +#define get_ue_golomb(a) get_ue(a, __FILE__, __func__, __LINE__) +#define get_se_golomb(a) get_se(a, __FILE__, __func__, __LINE__) +#define get_te_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__) +#define get_te0_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__) + +#endif /* TRACE */ + +/** + * write unsigned exp golomb code. + */ +static inline void set_ue_golomb(PutBitContext *pb, int i) +{ + assert(i >= 0); + + if (i < 256) + put_bits(pb, ff_ue_golomb_len[i], i + 1); + else { + int e = av_log2(i + 1); + put_bits(pb, 2 * e + 1, i + 1); + } +} + +/** + * write truncated unsigned exp golomb code. + */ +static inline void set_te_golomb(PutBitContext *pb, int i, int range) +{ + assert(range >= 1); + assert(i <= range); + + if (range == 2) + put_bits(pb, 1, i ^ 1); + else + set_ue_golomb(pb, i); +} + +/** + * write signed exp golomb code. 16 bits at most. + */ +static inline void set_se_golomb(PutBitContext *pb, int i) +{ + i = 2 * i - 1; + if (i < 0) + i ^= -1; //FIXME check if gcc does the right thing + set_ue_golomb(pb, i); +} + +/** + * write unsigned golomb rice code (ffv1). + */ +static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, + int esc_len) +{ + int e; + + assert(i >= 0); + + e = i >> k; + if (e < limit) + put_bits(pb, e + k + 1, (1 << k) + (i & ((1 << k) - 1))); + else + put_bits(pb, limit + esc_len, i - limit + 1); +} + +/** + * write unsigned golomb rice code (jpegls). + */ +static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, + int limit, int esc_len) +{ + int e; + + assert(i >= 0); + + e = (i >> k) + 1; + if (e < limit) { + while (e > 31) { + put_bits(pb, 31, 0); + e -= 31; + } + put_bits(pb, e, 1); + if (k) + put_sbits(pb, k, i); + } else { + while (limit > 31) { + put_bits(pb, 31, 0); + limit -= 31; + } + put_bits(pb, limit, 1); + put_bits(pb, esc_len, i - 1); + } +} + +/** + * write signed golomb rice code (ffv1). + */ +static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, + int esc_len) +{ + int v; + + v = -2 * i - 1; + v ^= (v >> 31); + + set_ur_golomb(pb, v, k, limit, esc_len); +} + +/** + * write signed golomb rice code (flac). + */ +static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k, + int limit, int esc_len) +{ + int v; + + v = -2 * i - 1; + v ^= (v >> 31); + + set_ur_golomb_jpegls(pb, v, k, limit, esc_len); +} + +#endif /* AVCODEC_GOLOMB_H */ diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 4fa2de0184..9b950ede20 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -32,7 +32,7 @@ #include "h264dec.h" #include "h264_mvpred.h" #include "h264data.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "mpegutils.h" #include <assert.h> diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index d694558ecc..cde46fa9eb 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -18,7 +18,7 @@ #include "bytestream.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "h264.h" #include "h264dec.h" #include "h264_parse.h" diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index b4da123e94..6de37c0b55 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -36,7 +36,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "h264.h" #include "h264_sei.h" #include "h264_ps.h" diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 7ee3876c8b..b3a0e8a7ed 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -28,12 +28,13 @@ #include <inttypes.h> #include "libavutil/imgutils.h" + +#include "golomb_legacy.h" #include "internal.h" #include "mathops.h" #include "avcodec.h" #include "h264data.h" #include "h264_ps.h" -#include "golomb.h" #define MAX_LOG2_MAX_FRAME_NUM (12 + 4) #define MIN_LOG2_MAX_FRAME_NUM 4 diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index 3c55998424..b4dc49cc41 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -27,11 +27,11 @@ #include <inttypes.h> +#include "golomb_legacy.h" #include "internal.h" #include "avcodec.h" #include "h264.h" #include "h264dec.h" -#include "golomb.h" #include "mpegutils.h" #include <assert.h> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 7eef3ee962..4bf001ae07 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "h264_ps.h" #include "h264_sei.h" #include "internal.h" diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 3749d1f2ca..f1f5fc05f9 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -34,6 +34,7 @@ #include "cabac.h" #include "cabac_functions.h" #include "error_resilience.h" +#include "golomb_legacy.h" #include "avcodec.h" #include "h264.h" #include "h264dec.h" @@ -41,7 +42,6 @@ #include "h264chroma.h" #include "h264_mvpred.h" #include "h264_ps.h" -#include "golomb.h" #include "mathops.h" #include "mpegutils.h" #include "rectangle.h" diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 834c60c38c..5137039188 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -36,6 +36,7 @@ #include "cabac_functions.h" #include "error_resilience.h" #include "avcodec.h" +#include "golomb_legacy.h" #include "h264.h" #include "h264dec.h" #include "h2645_parse.h" @@ -43,7 +44,6 @@ #include "h264chroma.h" #include "h264_mvpred.h" #include "h264_ps.h" -#include "golomb.h" #include "mathops.h" #include "me_cmp.h" #include "mpegutils.h" diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index 74a0257073..5129e3a9c1 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -22,7 +22,7 @@ #include "libavutil/common.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "hevc.h" #include "hevcdec.h" #include "h2645_parse.h" diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 4a5a47e20e..3c98e4ce44 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -25,7 +25,7 @@ #include "libavutil/imgutils.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "hevc_data.h" #include "hevc_ps.h" diff --git a/libavcodec/hevc_ps_enc.c b/libavcodec/hevc_ps_enc.c index 4864e6ebfc..1fb93b3020 100644 --- a/libavcodec/hevc_ps_enc.c +++ b/libavcodec/hevc_ps_enc.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "golomb.h" +#include "golomb_legacy.h" #include "hevc_ps.h" #include "put_bits.h" diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 8c913f93a7..1f8554ad5f 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -22,7 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "golomb.h" +#include "golomb_legacy.h" #include "hevcdec.h" enum HEVC_SEI_TYPE { diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index dcb2453a20..e24ce1e3c0 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -35,7 +35,7 @@ #include "bswapdsp.h" #include "bytestream.h" #include "cabac_functions.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "hevc.h" #include "hevc_data.h" #include "hevcdec.h" diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 9f8ccecec6..8d1e763113 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "internal.h" #include "mathops.h" #include "mjpeg.h" diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index cb9b71e4cd..fb3c69f2f9 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "internal.h" #include "mathops.h" #include "mjpeg.h" diff --git a/libavcodec/loco.c b/libavcodec/loco.c index f25ef61f37..8624ea86ad 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "internal.h" #include "mathops.h" diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index 9812837570..6bc0f3fa0d 100644 --- a/libavcodec/ralf.c +++ b/libavcodec/ralf.c @@ -30,7 +30,7 @@ #include "libavutil/channel_layout.h" #include "avcodec.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "internal.h" #include "unary_legacy.h" #include "ralfdata.h" diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 7218fa36dc..77e875bac9 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -25,9 +25,9 @@ */ #include "avcodec.h" +#include "golomb_legacy.h" #include "mpegutils.h" #include "mpegvideo.h" -#include "golomb.h" #include "rv34.h" #include "rv30data.h" diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 4220195a52..9fb0760ccb 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -28,9 +28,9 @@ #include "avcodec.h" #include "error_resilience.h" +#include "golomb_legacy.h" #include "mpegutils.h" #include "mpegvideo.h" -#include "golomb.h" #include "internal.h" #include "mathops.h" #include "mpeg_er.h" diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 0da13124d6..d46a44a5dd 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -27,9 +27,9 @@ #include "libavutil/imgutils.h" #include "avcodec.h" +#include "golomb_legacy.h" #include "mpegutils.h" #include "mpegvideo.h" -#include "golomb.h" #include "rv34.h" #include "rv40vlc2.h" diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 00d1661779..82fa2ab943 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "bytestream.h" #include "get_bits.h" -#include "golomb.h" +#include "golomb_legacy.h" #include "internal.h" #define MAX_CHANNELS 8 diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 51657372ae..8bbd331de3 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -43,12 +43,13 @@ #include <inttypes.h> #include "libavutil/attributes.h" + +#include "golomb_legacy.h" #include "internal.h" #include "avcodec.h" #include "mpegutils.h" #include "h264dec.h" #include "h264data.h" -#include "golomb.h" #include "hpeldsp.h" #include "mathops.h" #include "rectangle.h" diff --git a/libavcodec/tests/golomb.c b/libavcodec/tests/golomb.c index 7587402e24..d8fff71ca3 100644 --- a/libavcodec/tests/golomb.c +++ b/libavcodec/tests/golomb.c @@ -21,7 +21,7 @@ #include "libavutil/mem.h" -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" #include "libavcodec/put_bits.h" #include "libavcodec/golomb.h" @@ -33,7 +33,7 @@ int main(void) int i, ret = 0; uint8_t *temp; PutBitContext pb; - GetBitContext gb; + BitstreamContext bc; temp = av_malloc(SIZE); if (!temp) @@ -44,11 +44,11 @@ int main(void) set_ue_golomb(&pb, i); flush_put_bits(&pb); - init_get_bits(&gb, temp, 8 * SIZE); + bitstream_init8(&bc, temp, SIZE); for (i = 0; i < COUNT; i++) { - int j, s = show_bits(&gb, 25); + int j, s = bitstream_peek(&bc, 25); - j = get_ue_golomb(&gb); + j = get_ue_golomb(&bc); if (j != i) { fprintf(stderr, "get_ue_golomb: expected %d, got %d. bits: %7x\n", i, j, s); @@ -62,11 +62,11 @@ int main(void) set_ue_golomb(&pb, EXTEND(i)); flush_put_bits(&pb); - init_get_bits(&gb, temp, 8 * SIZE); + bitstream_init8(&bc, temp, SIZE); for (i = 0; i < COUNT; i++) { - int j, s = show_bits_long(&gb, 32); + int j, s = bitstream_peek(&bc, 32); - j = get_ue_golomb_long(&gb); + j = get_ue_golomb_long(&bc); if (j != EXTEND(i)) { fprintf(stderr, "get_ue_golomb_long: expected %d, got %d. " "bits: %8x\n", EXTEND(i), j, s); @@ -79,11 +79,11 @@ int main(void) set_se_golomb(&pb, i - COUNT / 2); flush_put_bits(&pb); - init_get_bits(&gb, temp, 8 * SIZE); + bitstream_init8(&bc, temp, SIZE); for (i = 0; i < COUNT; i++) { - int j, s = show_bits(&gb, 25); + int j, s = bitstream_peek(&bc, 25); - j = get_se_golomb(&gb); + j = get_se_golomb(&bc); if (j != i - COUNT / 2) { fprintf(stderr, "get_se_golomb: expected %d, got %d. bits: %7x\n", i - COUNT / 2, j, s); |