| 351 | */ |
| 352 | |
| 353 | static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent, int numBands) |
| 354 | { |
| 355 | int i,j,k,cnt; |
| 356 | int components, coding_mode_selector, coding_mode, coded_values_per_component; |
| 357 | int sfIndx, coded_values, max_coded_values, quant_step_index, coded_components; |
| 358 | int band_flags[4], mantissa[8]; |
| 359 | float *pCoef; |
| 360 | float scalefactor; |
| 361 | int component_count = 0; |
| 362 | |
| 363 | components = get_bits(gb,5); |
| 364 | |
| 365 | /* no tonal components */ |
| 366 | if (components == 0) |
| 367 | return 0; |
| 368 | |
| 369 | coding_mode_selector = get_bits(gb,2); |
| 370 | if (coding_mode_selector == 2) |
| 371 | return -1; |
| 372 | |
| 373 | coding_mode = coding_mode_selector & 1; |
| 374 | |
| 375 | for (i = 0; i < components; i++) { |
| 376 | for (cnt = 0; cnt <= numBands; cnt++) |
| 377 | band_flags[cnt] = get_bits1(gb); |
| 378 | |
| 379 | coded_values_per_component = get_bits(gb,3); |
| 380 | |
| 381 | quant_step_index = get_bits(gb,3); |
| 382 | if (quant_step_index <= 1) |
| 383 | return -1; |
| 384 | |
| 385 | if (coding_mode_selector == 3) |
| 386 | coding_mode = get_bits1(gb); |
| 387 | |
| 388 | for (j = 0; j < (numBands + 1) * 4; j++) { |
| 389 | if (band_flags[j >> 2] == 0) |
| 390 | continue; |
| 391 | |
| 392 | coded_components = get_bits(gb,3); |
| 393 | |
| 394 | for (k=0; k<coded_components; k++) { |
| 395 | sfIndx = get_bits(gb,6); |
| 396 | pComponent[component_count].pos = j * 64 + (get_bits(gb,6)); |
| 397 | max_coded_values = 1024 - pComponent[component_count].pos; |
| 398 | coded_values = coded_values_per_component + 1; |
| 399 | coded_values = FFMIN(max_coded_values,coded_values); |
| 400 | |
| 401 | scalefactor = sf_table[sfIndx] * iMaxQuant[quant_step_index]; |
| 402 | |
| 403 | readQuantSpectralCoeffs(gb, quant_step_index, coding_mode, mantissa, coded_values); |
| 404 | |
| 405 | pComponent[component_count].numCoefs = coded_values; |
| 406 | |
| 407 | /* inverse quant */ |
| 408 | pCoef = pComponent[component_count].coef; |
| 409 | for (cnt = 0; cnt < coded_values; cnt++) |
| 410 | pCoef[cnt] = mantissa[cnt] * scalefactor; |
no test coverage detected