1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avcodec/golomb: simplify sign conversion

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
zhaoxiu.zeng 2015-02-14 00:58:58 +08:00 committed by Michael Niedermayer
parent 0073c8e345
commit b11a187575

View File

@ -195,7 +195,7 @@ static inline int get_se_golomb(GetBitContext *gb)
return ff_se_golomb_vlc_code[buf];
} else {
int log = av_log2(buf);
int log = av_log2(buf), sign;
LAST_SKIP_BITS(re, gb, 31 - log);
UPDATE_CACHE(re, gb);
buf = GET_CACHE(re, gb);
@ -205,10 +205,8 @@ static inline int get_se_golomb(GetBitContext *gb)
LAST_SKIP_BITS(re, gb, 32 - log);
CLOSE_READER(re, gb);
if (buf & 1)
buf = -(buf >> 1);
else
buf = (buf >> 1);
sign = -(buf & 1);
buf = ((buf >> 1) ^ sign) - sign;
return buf;
}
@ -217,13 +215,10 @@ static inline int get_se_golomb(GetBitContext *gb)
static inline int get_se_golomb_long(GetBitContext *gb)
{
unsigned int buf = get_ue_golomb_long(gb);
int sign;
if (buf & 1)
buf = (buf + 1) >> 1;
else
buf = -(buf >> 1);
return buf;
sign = (buf & 1) - 1;
return ((buf >> 1) ^ sign) + 1;
}
static inline int svq3_get_se_golomb(GetBitContext *gb)
@ -264,13 +259,9 @@ static inline int dirac_get_se_golomb(GetBitContext *gb)
uint32_t ret = svq3_get_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);
int sign;
sign = -get_bits1(gb);
ret = (ret ^ sign) - sign;
}
return ret;
@ -372,14 +363,11 @@ 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);
int sign;
v++;
if (v & 1)
return v >> 1;
else
return -(v >> 1);
// return (v>>1) ^ -(v&1);
sign = (v & 1) - 1;
return ((v >> 1) ^ sign) - sign;
}
/**
@ -406,10 +394,7 @@ static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k)
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;
return (uvar >> 1) ^ -(uvar & 1);
}
#ifdef TRACE