MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decode_cce

Function decode_cce

libavcodec/aacdec.c:1503–1568  ·  view source on GitHub ↗

* Decode coupling_channel_element; reference: table 4.8. * * @param elem_id Identifies the instance of a syntax element. * * @return Returns error status. 0 - OK, !0 - error */

Source from the content-addressed store, hash-verified

1501 * @return Returns error status. 0 - OK, !0 - error
1502 */
1503static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
1504{
1505 int num_gain = 0;
1506 int c, g, sfb, ret;
1507 int sign;
1508 float scale;
1509 SingleChannelElement *sce = &che->ch[0];
1510 ChannelCoupling *coup = &che->coup;
1511
1512 coup->coupling_point = 2 * get_bits1(gb);
1513 coup->num_coupled = get_bits(gb, 3);
1514 for (c = 0; c <= coup->num_coupled; c++) {
1515 num_gain++;
1516 coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;
1517 coup->id_select[c] = get_bits(gb, 4);
1518 if (coup->type[c] == TYPE_CPE) {
1519 coup->ch_select[c] = get_bits(gb, 2);
1520 if (coup->ch_select[c] == 3)
1521 num_gain++;
1522 } else
1523 coup->ch_select[c] = 2;
1524 }
1525 coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1);
1526
1527 sign = get_bits(gb, 1);
1528 scale = pow(2., pow(2., (int)get_bits(gb, 2) - 3));
1529
1530 if ((ret = decode_ics(ac, sce, gb, 0, 0)))
1531 return ret;
1532
1533 for (c = 0; c < num_gain; c++) {
1534 int idx = 0;
1535 int cge = 1;
1536 int gain = 0;
1537 float gain_cache = 1.;
1538 if (c) {
1539 cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);
1540 gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;
1541 gain_cache = pow(scale, -gain);
1542 }
1543 if (coup->coupling_point == AFTER_IMDCT) {
1544 coup->gain[c][0] = gain_cache;
1545 } else {
1546 for (g = 0; g < sce->ics.num_window_groups; g++) {
1547 for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {
1548 if (sce->band_type[idx] != ZERO_BT) {
1549 if (!cge) {
1550 int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
1551 if (t) {
1552 int s = 1;
1553 t = gain += t;
1554 if (sign) {
1555 s -= 2 * (t & 0x1);
1556 t >>= 1;
1557 }
1558 gain_cache = pow(scale, -t) * s;
1559 }
1560 }

Callers 1

aac_decode_frameFunction · 0.85

Calls 4

get_bits1Function · 0.85
get_bitsFunction · 0.85
decode_icsFunction · 0.85
get_vlc2Function · 0.85

Tested by

no test coverage detected