| 454 | } |
| 455 | |
| 456 | static int decode_cdlms(WmallDecodeCtx *s) |
| 457 | { |
| 458 | int c, i; |
| 459 | int cdlms_send_coef = get_bits1(&s->gb); |
| 460 | |
| 461 | for (c = 0; c < s->num_channels; c++) { |
| 462 | s->cdlms_ttl[c] = get_bits(&s->gb, 3) + 1; |
| 463 | for (i = 0; i < s->cdlms_ttl[c]; i++) { |
| 464 | s->cdlms[c][i].order = (get_bits(&s->gb, 7) + 1) * 8; |
| 465 | if (s->cdlms[c][i].order > MAX_ORDER) { |
| 466 | av_log(s->avctx, AV_LOG_ERROR, |
| 467 | "Order[%d][%d] %d > max (%d), not supported\n", |
| 468 | c, i, s->cdlms[c][i].order, MAX_ORDER); |
| 469 | s->cdlms[0][0].order = 0; |
| 470 | return AVERROR_INVALIDDATA; |
| 471 | } |
| 472 | if(s->cdlms[c][i].order & 8 && s->bits_per_sample == 16) { |
| 473 | static int warned; |
| 474 | if(!warned) |
| 475 | avpriv_request_sample(s->avctx, "CDLMS of order %d", |
| 476 | s->cdlms[c][i].order); |
| 477 | warned = 1; |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | for (i = 0; i < s->cdlms_ttl[c]; i++) |
| 482 | s->cdlms[c][i].scaling = get_bits(&s->gb, 4); |
| 483 | |
| 484 | if (cdlms_send_coef) { |
| 485 | for (i = 0; i < s->cdlms_ttl[c]; i++) { |
| 486 | int cbits, shift_l, shift_r, j; |
| 487 | cbits = av_log2(s->cdlms[c][i].order); |
| 488 | if ((1 << cbits) < s->cdlms[c][i].order) |
| 489 | cbits++; |
| 490 | s->cdlms[c][i].coefsend = get_bits(&s->gb, cbits) + 1; |
| 491 | |
| 492 | cbits = av_log2(s->cdlms[c][i].scaling + 1); |
| 493 | if ((1 << cbits) < s->cdlms[c][i].scaling + 1) |
| 494 | cbits++; |
| 495 | |
| 496 | s->cdlms[c][i].bitsend = get_bitsz(&s->gb, cbits) + 2; |
| 497 | shift_l = 32 - s->cdlms[c][i].bitsend; |
| 498 | shift_r = 32 - s->cdlms[c][i].scaling - 2; |
| 499 | for (j = 0; j < s->cdlms[c][i].coefsend; j++) |
| 500 | s->cdlms[c][i].coefs[j] = |
| 501 | (get_bits(&s->gb, s->cdlms[c][i].bitsend) << shift_l) >> shift_r; |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | for (i = 0; i < s->cdlms_ttl[c]; i++) |
| 506 | memset(s->cdlms[c][i].coefs + s->cdlms[c][i].order, |
| 507 | 0, WMALL_COEFF_PAD_SIZE); |
| 508 | } |
| 509 | |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size) |
no test coverage detected