5.4.1 - Primary audio coding side information
| 402 | |
| 403 | // 5.4.1 - Primary audio coding side information |
| 404 | static int parse_subframe_header(DCACoreDecoder *s, int sf, |
| 405 | enum HeaderType header, int xch_base) |
| 406 | { |
| 407 | int ch, band, ret; |
| 408 | |
| 409 | if (get_bits_left(&s->gb) < 0) |
| 410 | return AVERROR_INVALIDDATA; |
| 411 | |
| 412 | if (header == HEADER_CORE) { |
| 413 | // Subsubframe count |
| 414 | s->nsubsubframes[sf] = get_bits(&s->gb, 2) + 1; |
| 415 | |
| 416 | // Partial subsubframe sample count |
| 417 | skip_bits(&s->gb, 3); |
| 418 | } |
| 419 | |
| 420 | // Prediction mode |
| 421 | for (ch = xch_base; ch < s->nchannels; ch++) |
| 422 | for (band = 0; band < s->nsubbands[ch]; band++) |
| 423 | s->prediction_mode[ch][band] = get_bits1(&s->gb); |
| 424 | |
| 425 | // Prediction coefficients VQ address |
| 426 | for (ch = xch_base; ch < s->nchannels; ch++) |
| 427 | for (band = 0; band < s->nsubbands[ch]; band++) |
| 428 | if (s->prediction_mode[ch][band]) |
| 429 | s->prediction_vq_index[ch][band] = get_bits(&s->gb, 12); |
| 430 | |
| 431 | // Bit allocation index |
| 432 | for (ch = xch_base; ch < s->nchannels; ch++) { |
| 433 | int sel = s->bit_allocation_sel[ch]; |
| 434 | |
| 435 | for (band = 0; band < s->subband_vq_start[ch]; band++) { |
| 436 | int abits; |
| 437 | |
| 438 | if (sel < 5) |
| 439 | abits = dca_get_vlc(&s->gb, &ff_dca_vlc_bit_allocation[sel]); |
| 440 | else |
| 441 | abits = get_bits(&s->gb, sel - 1); |
| 442 | |
| 443 | if (abits > DCA_ABITS_MAX) { |
| 444 | av_log(s->avctx, AV_LOG_ERROR, "Invalid bit allocation index\n"); |
| 445 | return AVERROR_INVALIDDATA; |
| 446 | } |
| 447 | |
| 448 | s->bit_allocation[ch][band] = abits; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | // Transition mode |
| 453 | for (ch = xch_base; ch < s->nchannels; ch++) { |
| 454 | // Clear transition mode for all subbands |
| 455 | memset(s->transition_mode[sf][ch], 0, sizeof(s->transition_mode[0][0])); |
| 456 | |
| 457 | // Transient possible only if more than one subsubframe |
| 458 | if (s->nsubsubframes[sf] > 1) { |
| 459 | int sel = s->transition_mode_sel[ch]; |
| 460 | for (band = 0; band < s->subband_vq_start[ch]; band++) |
| 461 | if (s->bit_allocation[ch][band]) |
no test coverage detected