summaryrefslogtreecommitdiff
path: root/libavcodec/apedec.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2009-11-20 07:49:53 +0000
committerKostya Shishkov <kostya.shishkov@gmail.com>2009-11-20 07:49:53 +0000
commit76267e4e90a3b64f98ca0e4517eff44e963d5e18 (patch)
treecd16e442cd423ed4296584b7651429d468434002 /libavcodec/apedec.c
parente4de5b0fb54d227d2683a7c69641a6369492680c (diff)
Implement missing case for decoding samples with large pivot value in APE
decoder. This fixes issue 1555 Originally committed as revision 20560 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/apedec.c')
-rw-r--r--libavcodec/apedec.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 1e21e6a401..20ebe9ed67 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -408,8 +408,24 @@ static inline int ape_decode_value(APEContext * ctx, APERice *rice)
overflow |= range_decode_bits(ctx, 16);
}
- base = range_decode_culfreq(ctx, pivot);
- range_decode_update(ctx, 1, base);
+ if (pivot < 0x10000) {
+ base = range_decode_culfreq(ctx, pivot);
+ range_decode_update(ctx, 1, base);
+ } else {
+ int base_hi = pivot, base_lo;
+ int bbits = 0;
+
+ while (base_hi & ~0xFFFF) {
+ base_hi >>= 1;
+ bbits++;
+ }
+ base_hi = range_decode_culfreq(ctx, base_hi + 1);
+ range_decode_update(ctx, 1, base_hi);
+ base_lo = range_decode_culfreq(ctx, 1 << bbits);
+ range_decode_update(ctx, 1, base_lo);
+
+ base = (base_hi << bbits) + base_lo;
+ }
x = base + overflow * pivot;
}