diff options
author | zhaoxiu.zeng <zhaoxiu.zeng@gmail.com> | 2015-02-14 00:56:28 +0800 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-14 01:09:44 +0100 |
commit | ac7fc444eed553d5010c5860f2e91bfa42628e08 (patch) | |
tree | 974631ac6bebad9458d67e43049f1ca51c1bcd80 /libavcodec/apedec.c | |
parent | b11a187575f6262c0941fdbb1cd3fd7ffd819500 (diff) | |
download | ffmpeg-ac7fc444eed553d5010c5860f2e91bfa42628e08.tar.gz |
avcodec/apedec: simplify sign conversion
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/apedec.c')
-rw-r--r-- | libavcodec/apedec.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index f1ddf80292..536361cd84 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -505,10 +505,7 @@ static inline int ape_decode_value_3860(APEContext *ctx, GetBitContext *gb, rice->k++; /* Convert to signed */ - if (x & 1) - return (x >> 1) + 1; - else - return -(x >> 1); + return ((x >> 1) ^ ((x & 1) - 1)) + 1; } static inline int ape_decode_value_3900(APEContext *ctx, APERice *rice) @@ -542,10 +539,7 @@ static inline int ape_decode_value_3900(APEContext *ctx, APERice *rice) update_rice(rice, x); /* Convert to signed */ - if (x & 1) - return (x >> 1) + 1; - else - return -(x >> 1); + return ((x >> 1) ^ ((x & 1) - 1)) + 1; } static inline int ape_decode_value_3990(APEContext *ctx, APERice *rice) @@ -588,10 +582,7 @@ static inline int ape_decode_value_3990(APEContext *ctx, APERice *rice) update_rice(rice, x); /* Convert to signed */ - if (x & 1) - return (x >> 1) + 1; - else - return -(x >> 1); + return ((x >> 1) ^ ((x & 1) - 1)) + 1; } static void decode_array_0000(APEContext *ctx, GetBitContext *gb, @@ -634,12 +625,8 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb, } } - for (i = 0; i < blockstodecode; i++) { - if (out[i] & 1) - out[i] = (out[i] >> 1) + 1; - else - out[i] = -(out[i] >> 1); - } + for (i = 0; i < blockstodecode; i++) + out[i] = ((out[i] >> 1) ^ ((out[i] & 1) - 1)) + 1; } static void entropy_decode_mono_0000(APEContext *ctx, int blockstodecode) |