[FFmpeg-cvslog] flacdec: simplify loop in decode_residuals()
Mans Rullgard
git at videolan.org
Tue Aug 21 16:52:32 CEST 2012
ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Mon Jul 2 22:39:34 2012 +0100| [ea98507db018c7b0ea7a167281a210ba1328dde7] | committer: Mans Rullgard
flacdec: simplify loop in decode_residuals()
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea98507db018c7b0ea7a167281a210ba1328dde7
---
libavcodec/flacdec.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 3cdd957..01099bf 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);
More information about the ffmpeg-cvslog
mailing list