Reads the block data for a non-constant block */
| 573 | /** Reads the block data for a non-constant block |
| 574 | */ |
| 575 | static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd) |
| 576 | { |
| 577 | ALSSpecificConfig *sconf = &ctx->sconf; |
| 578 | AVCodecContext *avctx = ctx->avctx; |
| 579 | GetBitContext *gb = &ctx->gb; |
| 580 | unsigned int k; |
| 581 | unsigned int s[8]; |
| 582 | unsigned int sx[8]; |
| 583 | unsigned int sub_blocks, log2_sub_blocks, sb_length; |
| 584 | unsigned int start = 0; |
| 585 | unsigned int opt_order; |
| 586 | int sb; |
| 587 | int32_t *quant_cof = bd->quant_cof; |
| 588 | int32_t *current_res; |
| 589 | |
| 590 | |
| 591 | // ensure variable block decoding by reusing this field |
| 592 | bd->const_block = 0; |
| 593 | |
| 594 | bd->opt_order = 1; |
| 595 | bd->js_blocks = get_bits1(gb); |
| 596 | |
| 597 | opt_order = bd->opt_order; |
| 598 | |
| 599 | // determine the number of subblocks for entropy decoding |
| 600 | if (!sconf->bgmc && !sconf->sb_part) { |
| 601 | log2_sub_blocks = 0; |
| 602 | } else { |
| 603 | if (sconf->bgmc && sconf->sb_part) |
| 604 | log2_sub_blocks = get_bits(gb, 2); |
| 605 | else |
| 606 | log2_sub_blocks = 2 * get_bits1(gb); |
| 607 | } |
| 608 | |
| 609 | sub_blocks = 1 << log2_sub_blocks; |
| 610 | |
| 611 | // do not continue in case of a damaged stream since |
| 612 | // block_length must be evenly divisible by sub_blocks |
| 613 | if (bd->block_length & (sub_blocks - 1)) { |
| 614 | av_log(avctx, AV_LOG_WARNING, |
| 615 | "Block length is not evenly divisible by the number of subblocks.\n"); |
| 616 | return -1; |
| 617 | } |
| 618 | |
| 619 | sb_length = bd->block_length >> log2_sub_blocks; |
| 620 | |
| 621 | if (sconf->bgmc) { |
| 622 | s[0] = get_bits(gb, 8 + (sconf->resolution > 1)); |
| 623 | for (k = 1; k < sub_blocks; k++) |
| 624 | s[k] = s[k - 1] + decode_rice(gb, 2); |
| 625 | |
| 626 | for (k = 0; k < sub_blocks; k++) { |
| 627 | sx[k] = s[k] & 0x0F; |
| 628 | s [k] >>= 4; |
| 629 | } |
| 630 | } else { |
| 631 | s[0] = get_bits(gb, 4 + (sconf->resolution > 1)); |
| 632 | for (k = 1; k < sub_blocks; k++) |
no test coverage detected