| 768 | } |
| 769 | |
| 770 | static int parse_bit_alloc(DBEDecodeContext *s1, DBEChannel *c) |
| 771 | { |
| 772 | DBEContext *s = &s1->dectx; |
| 773 | DBEGroup *p, *g; |
| 774 | int bap_strategy[MAX_GROUPS], fg_spc[MAX_GROUPS]; |
| 775 | int fg_ofs[MAX_GROUPS], msk_mod[MAX_GROUPS]; |
| 776 | int i, snr_ofs; |
| 777 | |
| 778 | for (i = 0; i < c->nb_groups; i++) { |
| 779 | bap_strategy[i] = !i || get_bits1(&s->gb); |
| 780 | if (bap_strategy[i]) { |
| 781 | fg_spc[i] = get_bits(&s->gb, 2); |
| 782 | fg_ofs[i] = get_bits(&s->gb, 3); |
| 783 | msk_mod[i] = get_bits1(&s->gb); |
| 784 | } else { |
| 785 | fg_spc[i] = fg_spc[i - 1]; |
| 786 | fg_ofs[i] = fg_ofs[i - 1]; |
| 787 | msk_mod[i] = msk_mod[i - 1]; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | if (get_bits1(&s->gb)) { |
| 792 | avpriv_report_missing_feature(s->avctx, "Delta bit allocation"); |
| 793 | return AVERROR_PATCHWELCOME; |
| 794 | } |
| 795 | |
| 796 | snr_ofs = get_bits(&s->gb, 8); |
| 797 | if (!snr_ofs) { |
| 798 | memset(c->bap, 0, sizeof(c->bap)); |
| 799 | return 0; |
| 800 | } |
| 801 | |
| 802 | for (i = 0, p = NULL, g = c->groups; i < c->nb_groups; i++, p = g, g++) { |
| 803 | if (c->exp_strategy[i] || bap_strategy[i]) { |
| 804 | bit_allocate(g->nb_exponent, g->imdct_idx, s->metadata.fr_code, |
| 805 | c->exponents + g->exp_ofs, c->bap + g->exp_ofs, |
| 806 | fg_spc[i], fg_ofs[i], msk_mod[i], snr_ofs); |
| 807 | } else { |
| 808 | memcpy(c->bap + g->exp_ofs, |
| 809 | c->bap + p->exp_ofs, |
| 810 | g->nb_exponent * sizeof(c->bap[0])); |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | return 0; |
| 815 | } |
| 816 | |
| 817 | static int parse_indices(DBEContext *s, DBEChannel *c) |
| 818 | { |
no test coverage detected