aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/alac.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-07-09 10:33:28 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-07-19 13:26:45 -0400
commitd9837434a91dbb3632df335414aad538e5b0a6e9 (patch)
tree8ca43b0fc3a068dcb9b1f0289a7b0074999beccc /libavcodec/alac.c
parent6e91f62256db72b056f6bc61106809d3994f8e26 (diff)
downloadffmpeg-d9837434a91dbb3632df335414aad538e5b0a6e9.tar.gz
alac: limit the rice param before passing to decode_scalar()
reduces the number of parameters to decode_scalar() and slightly simplifies the code
Diffstat (limited to 'libavcodec/alac.c')
-rw-r--r--libavcodec/alac.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 8824ae8377..76ef4998d6 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -77,17 +77,14 @@ typedef struct {
int extra_bits; /**< number of extra bits beyond 16-bit */
} ALACContext;
-static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){
+static inline int decode_scalar(GetBitContext *gb, int k, int readsamplesize)
+{
int x = get_unary_0_9(gb);
if (x > 8) { /* RICE THRESHOLD */
/* use alternative encoding */
x = get_bits(gb, readsamplesize);
- } else {
- if (k >= limit)
- k = limit;
-
- if (k != 1) {
+ } else if (k != 1) {
int extrabits = show_bits(gb, k);
/* multiply x by 2^k - 1, as part of their strange algorithm */
@@ -98,7 +95,6 @@ static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsam
skip_bits(gb, k);
} else
skip_bits(gb, k - 1);
- }
}
return x;
}
@@ -123,7 +119,8 @@ static void bastardized_rice_decompress(ALACContext *alac,
/* read k, that is bits as is */
k = av_log2((history >> 9) + 3);
- x = decode_scalar(&alac->gb, k, alac->rice_limit, readsamplesize);
+ k = FFMIN(k, alac->rice_limit);
+ x = decode_scalar(&alac->gb, k, readsamplesize);
x_modified = sign_modifier + x;
final_val = (x_modified + 1) / 2;
@@ -148,8 +145,9 @@ static void bastardized_rice_decompress(ALACContext *alac,
sign_modifier = 1;
k = 7 - av_log2(history) + ((history + 16) >> 6 /* / 64 */);
+ k = FFMIN(k, alac->rice_limit);
- block_size = decode_scalar(&alac->gb, k, alac->rice_limit, 16);
+ block_size = decode_scalar(&alac->gb, k, 16);
if (block_size > 0) {
if(block_size >= output_size - output_count){