comparison apedec.c @ 10545:e5a8a6b9a717 libavcodec

Implement missing case for decoding samples with large pivot value in APE decoder. This fixes issue 1555
author kostya
date Fri, 20 Nov 2009 07:49:53 +0000
parents b33c75c58ffe
children 79f3ead3ebc1
comparison
equal deleted inserted replaced
10544:b9fdb6b4c2dc 10545:e5a8a6b9a717
406 if (overflow == (MODEL_ELEMENTS - 1)) { 406 if (overflow == (MODEL_ELEMENTS - 1)) {
407 overflow = range_decode_bits(ctx, 16) << 16; 407 overflow = range_decode_bits(ctx, 16) << 16;
408 overflow |= range_decode_bits(ctx, 16); 408 overflow |= range_decode_bits(ctx, 16);
409 } 409 }
410 410
411 base = range_decode_culfreq(ctx, pivot); 411 if (pivot < 0x10000) {
412 range_decode_update(ctx, 1, base); 412 base = range_decode_culfreq(ctx, pivot);
413 range_decode_update(ctx, 1, base);
414 } else {
415 int base_hi = pivot, base_lo;
416 int bbits = 0;
417
418 while (base_hi & ~0xFFFF) {
419 base_hi >>= 1;
420 bbits++;
421 }
422 base_hi = range_decode_culfreq(ctx, base_hi + 1);
423 range_decode_update(ctx, 1, base_hi);
424 base_lo = range_decode_culfreq(ctx, 1 << bbits);
425 range_decode_update(ctx, 1, base_lo);
426
427 base = (base_hi << bbits) + base_lo;
428 }
413 429
414 x = base + overflow * pivot; 430 x = base + overflow * pivot;
415 } 431 }
416 432
417 update_rice(rice, x); 433 update_rice(rice, x);