Revision 891bd2e5 libavcodec/wma.c

View differences:

libavcodec/wma.c
426 426
}
427 427

  
428 428
/**
429
 * Decode an uncompressed coefficient.
430
 * @param s codec context
431
 * @return the decoded coefficient
432
 */
433
unsigned int ff_wma_get_large_val(GetBitContext* gb)
434
{
435
    /** consumes up to 34 bits */
436
    int n_bits = 8;
437
    /** decode length */
438
    if (get_bits1(gb)) {
439
        n_bits += 8;
440
        if (get_bits1(gb)) {
441
            n_bits += 8;
442
            if (get_bits1(gb)) {
443
                n_bits += 7;
444
            }
445
        }
446
    }
447
    return get_bits_long(gb, n_bits);
448
}
449

  
450
/**
429 451
 * Decode run level compressed coefficients.
430 452
 * @param avctx codec context
431 453
 * @param gb bitstream reader context
......
450 472
{
451 473
    int code, run, level, sign;
452 474
    WMACoef* eptr = ptr + num_coefs;
475
    ptr += offset;
453 476
    for(;;) {
454 477
        code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX);
455 478
        if (code < 0)
......
459 482
            break;
460 483
        } else if (code == 0) {
461 484
            /* escape */
485
            if (!version) {
462 486
            level = get_bits(gb, coef_nb_bits);
463 487
            /* NOTE: this is rather suboptimal. reading
464 488
               block_len_bits would be better */
465 489
            run = get_bits(gb, frame_len_bits);
490
            } else {
491
                level = ff_wma_get_large_val(gb);
492
                /** escape decode */
493
                if (get_bits1(gb)) {
494
                    if (get_bits1(gb)) {
495
                        if (get_bits1(gb)) {
496
                            av_log(avctx,AV_LOG_ERROR,
497
                                "broken escape sequence\n");
498
                            return -1;
499
                        } else
500
                            run = get_bits(gb, frame_len_bits) + 4;
501
                    } else
502
                        run = get_bits(gb, 2) + 1;
503
                } else
504
                     run = 0;
505
            }
466 506
        } else {
467 507
            /* normal code */
468 508
            run = run_table[code];

Also available in: Unified diff