mirror of https://git.ffmpeg.org/ffmpeg.git
alac: limit the rice param before passing to decode_scalar()
reduces the number of parameters to decode_scalar() and slightly simplifies the code
This commit is contained in:
parent
6e91f62256
commit
d9837434a9
|
@ -77,17 +77,14 @@ typedef struct {
|
||||||
int extra_bits; /**< number of extra bits beyond 16-bit */
|
int extra_bits; /**< number of extra bits beyond 16-bit */
|
||||||
} ALACContext;
|
} 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);
|
int x = get_unary_0_9(gb);
|
||||||
|
|
||||||
if (x > 8) { /* RICE THRESHOLD */
|
if (x > 8) { /* RICE THRESHOLD */
|
||||||
/* use alternative encoding */
|
/* use alternative encoding */
|
||||||
x = get_bits(gb, readsamplesize);
|
x = get_bits(gb, readsamplesize);
|
||||||
} else {
|
} else if (k != 1) {
|
||||||
if (k >= limit)
|
|
||||||
k = limit;
|
|
||||||
|
|
||||||
if (k != 1) {
|
|
||||||
int extrabits = show_bits(gb, k);
|
int extrabits = show_bits(gb, k);
|
||||||
|
|
||||||
/* multiply x by 2^k - 1, as part of their strange algorithm */
|
/* multiply x by 2^k - 1, as part of their strange algorithm */
|
||||||
|
@ -99,7 +96,6 @@ static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsam
|
||||||
} else
|
} else
|
||||||
skip_bits(gb, k - 1);
|
skip_bits(gb, k - 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +119,8 @@ static void bastardized_rice_decompress(ALACContext *alac,
|
||||||
|
|
||||||
/* read k, that is bits as is */
|
/* read k, that is bits as is */
|
||||||
k = av_log2((history >> 9) + 3);
|
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;
|
x_modified = sign_modifier + x;
|
||||||
final_val = (x_modified + 1) / 2;
|
final_val = (x_modified + 1) / 2;
|
||||||
|
@ -148,8 +145,9 @@ static void bastardized_rice_decompress(ALACContext *alac,
|
||||||
sign_modifier = 1;
|
sign_modifier = 1;
|
||||||
|
|
||||||
k = 7 - av_log2(history) + ((history + 16) >> 6 /* / 64 */);
|
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 > 0) {
|
||||||
if(block_size >= output_size - output_count){
|
if(block_size >= output_size - output_count){
|
||||||
|
|
Loading…
Reference in New Issue