| 386 | } |
| 387 | |
| 388 | static int decode_subframe(TAKDecContext *s, int32_t *decoded, |
| 389 | int subframe_size, int prev_subframe_size) |
| 390 | { |
| 391 | GetBitContext *gb = &s->gb; |
| 392 | int x, y, i, j, ret = 0; |
| 393 | int dshift, size, filter_quant, filter_order; |
| 394 | int tfilter[MAX_PREDICTORS]; |
| 395 | |
| 396 | if (!get_bits1(gb)) |
| 397 | return decode_residues(s, decoded, subframe_size); |
| 398 | |
| 399 | filter_order = predictor_sizes[get_bits(gb, 4)]; |
| 400 | |
| 401 | if (prev_subframe_size > 0 && get_bits1(gb)) { |
| 402 | if (filter_order > prev_subframe_size) |
| 403 | return AVERROR_INVALIDDATA; |
| 404 | |
| 405 | decoded -= filter_order; |
| 406 | subframe_size += filter_order; |
| 407 | |
| 408 | if (filter_order > subframe_size) |
| 409 | return AVERROR_INVALIDDATA; |
| 410 | } else { |
| 411 | int lpc_mode; |
| 412 | |
| 413 | if (filter_order > subframe_size) |
| 414 | return AVERROR_INVALIDDATA; |
| 415 | |
| 416 | lpc_mode = get_bits(gb, 2); |
| 417 | if (lpc_mode > 2) |
| 418 | return AVERROR_INVALIDDATA; |
| 419 | |
| 420 | if ((ret = decode_residues(s, decoded, filter_order)) < 0) |
| 421 | return ret; |
| 422 | |
| 423 | if (lpc_mode) |
| 424 | decode_lpc(decoded, lpc_mode, filter_order); |
| 425 | } |
| 426 | |
| 427 | dshift = get_bits_esc4(gb); |
| 428 | size = get_bits1(gb) + 6; |
| 429 | |
| 430 | filter_quant = 10; |
| 431 | if (get_bits1(gb)) { |
| 432 | filter_quant -= get_bits(gb, 3) + 1; |
| 433 | if (filter_quant < 3) |
| 434 | return AVERROR_INVALIDDATA; |
| 435 | } |
| 436 | |
| 437 | if (get_bits_left(gb) < 2*10 + 2*size) |
| 438 | return AVERROR_INVALIDDATA; |
| 439 | |
| 440 | s->predictors[0] = get_sbits(gb, 10); |
| 441 | s->predictors[1] = get_sbits(gb, 10); |
| 442 | s->predictors[2] = get_sbits(gb, size) * (1 << (10 - size)); |
| 443 | s->predictors[3] = get_sbits(gb, size) * (1 << (10 - size)); |
| 444 | if (filter_order > 4) { |
| 445 | int tmp = size - get_bits1(gb); |
no test coverage detected