Unified · Split
| @@ -1508,6 +1508,20 @@ static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64 · 1507 unmodified lines | ||
| 1508 | 1508 | |
| 1509 | 1509 | //printf("%d\n", ps->iid_index[env][bk]); |
| 1510 | 1510 | |
| 1511 | + /* index range is supposed to be -7...7 or -15...15 depending on iid_mode | |
| 1512 | + (Table 8.24, ISO/IEC 14496-3:2005). | |
| 1513 | + if it is outside these boundaries, this is most likely an error. sanitize | |
| 1514 | + it and try to process further. */ | |
| 1515 | + if (ps->iid_index[env][bk] < -no_iid_steps) { | |
| 1516 | + fprintf(stderr, "Warning: invalid iid_index: %d < %d\n", ps->iid_index[env][bk], | |
| 1517 | + -no_iid_steps); | |
| 1518 | + ps->iid_index[env][bk] = -no_iid_steps; | |
| 1519 | + } else if (ps->iid_index[env][bk] > no_iid_steps) { | |
| 1520 | + fprintf(stderr, "Warning: invalid iid_index: %d > %d\n", ps->iid_index[env][bk], | |
| 1521 | + no_iid_steps); | |
| 1522 | + ps->iid_index[env][bk] = no_iid_steps; | |
| 1523 | + } | |
| 1524 | + | |
| 1511 | 1525 | /* calculate the scalefactors c_1 and c_2 from the intensity differences */ |
| 1512 | 1526 | c_1 = sf_iid[no_iid_steps + ps->iid_index[env][bk]]; |
| 1513 | 1527 | c_2 = sf_iid[no_iid_steps - ps->iid_index[env][bk]]; |
| @@ -915,18 +915,18 @@ uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics, · 914 unmodified lines | ||
| 915 | 915 | /* element_output_channels not set yet */ |
| 916 | 916 | hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; |
| 917 | 917 | } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) { |
| 918 | − /* element inconsistency */ | |
| 919 | − | |
| 920 | − /* this only happens if PS is actually found but not in the first frame | |
| 918 | + /* element inconsistency | |
| 919 | + * this only happens if PS is actually found but not in the first frame | |
| 921 | 920 | * this means that there is only 1 bitstream element! |
| 922 | 921 | */ |
| 923 | 922 | |
| 924 | − /* reset the allocation */ | |
| 925 | − hDecoder->element_alloced[hDecoder->fr_ch_ele] = 0; | |
| 926 | − | |
| 927 | − hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; | |
| 928 | − | |
| 929 | − //return 21; | |
| 923 | + if (hDecoder->fr_channels == 1) { | |
| 924 | + /* reset the allocation */ | |
| 925 | + hDecoder->element_alloced[hDecoder->fr_ch_ele] = 0; | |
| 926 | + hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; | |
| 927 | + } else { | |
| 928 | + return 21; | |
| 929 | + } | |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) |