diff options
author | Mans Rullgard <mans@mansr.com> | 2012-07-03 01:39:34 +0400 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2012-08-21 14:23:13 +0400 |
commit | ea98507db018c7b0ea7a167281a210ba1328dde7 (patch) | |
tree | 85a6d14bea537adf478b86056390de1f215d7d1c /libavcodec/flacdec.c | |
parent | 957521e7a464efa542291176e0de6ef9e95205b5 (diff) |
flacdec: simplify loop in decode_residuals()
Diffstat (limited to 'libavcodec/flacdec.c')
-rw-r--r-- | libavcodec/flacdec.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 3cdd957a55..01099bf32b 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -207,6 +207,7 @@ static int get_metadata_size(const uint8_t *buf, int buf_size) static int decode_residuals(FLACContext *s, int channel, int pred_order) { int i, tmp, partition, method_type, rice_order; + int rice_bits, rice_esc; int sample = 0, samples; method_type = get_bits(&s->gb, 2); @@ -225,11 +226,14 @@ static int decode_residuals(FLACContext *s, int channel, int pred_order) return -1; } + rice_bits = 4 + method_type; + rice_esc = (1 << rice_bits) - 1; + sample= i= pred_order; for (partition = 0; partition < (1 << rice_order); partition++) { - tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5); - if (tmp == (method_type == 0 ? 15 : 31)) { + tmp = get_bits(&s->gb, rice_bits); + if (tmp == rice_esc) { tmp = get_bits(&s->gb, 5); for (; i < samples; i++, sample++) s->decoded[channel][sample] = get_sbits_long(&s->gb, tmp); |