aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-01-12 23:32:56 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-13 18:54:50 +0100
commitda144c2ddd8cb002540c219dce9ef4303d2b4ee5 (patch)
treec08bb0bebdaf005c13e935080af5abdf1df80099 /libavcodec
parent9006567bae4ac5e218a7eda79327797d53ef67c8 (diff)
downloadffmpeg-da144c2ddd8cb002540c219dce9ef4303d2b4ee5.tar.gz
avcodec/diracdec: Inline svq3_get_ue_golomb() and merge the sign bit decoding into it
This avoids closing and opening the bit reader Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/diracdec.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index c67f845712..fe879bb726 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -485,13 +485,44 @@ static av_cold int dirac_decode_end(AVCodecContext *avctx)
static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
{
int sign, coeff;
+ uint32_t buf;
- coeff = svq3_get_ue_golomb(gb);
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf = GET_CACHE(re, gb);
+
+ if (buf & 0xAA800000) {
+ buf >>= 32 - 8;
+ SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
+
+ coeff = ff_interleaved_ue_golomb_vlc_code[buf];
+ } else {
+ unsigned ret = 1;
+
+ do {
+ buf >>= 32 - 8;
+ 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 (ret<0x8000000U && BITS_AVAILABLE(re, gb));
+
+ coeff = ret - 1;
+ }
if (coeff) {
coeff = (coeff * qfactor + qoffset + 2) >> 2;
- sign = get_bits1(gb);
- coeff = (coeff ^ -sign) + sign;
+ sign = SHOW_SBITS(re, gb, 1);
+ LAST_SKIP_BITS(re, gb, 1);
+ coeff = (coeff ^ sign) - sign;
}
+ CLOSE_READER(re, gb);
return coeff;
}