| 286 | |
| 287 | |
| 288 | byte Unpack::DecodeAudio(int Delta) |
| 289 | { |
| 290 | struct AudioVariables *V=&AudV[UnpCurChannel]; |
| 291 | V->ByteCount++; |
| 292 | V->D4=V->D3; |
| 293 | V->D3=V->D2; |
| 294 | V->D2=V->LastDelta-V->D1; |
| 295 | V->D1=V->LastDelta; |
| 296 | int PCh=8*V->LastChar+V->K1*V->D1+V->K2*V->D2+V->K3*V->D3+V->K4*V->D4+V->K5*UnpChannelDelta; |
| 297 | PCh=(PCh>>3) & 0xFF; |
| 298 | |
| 299 | uint Ch=PCh-Delta; |
| 300 | |
| 301 | int D=(signed char)Delta; |
| 302 | // Left shift of negative value is undefined behavior in C++, |
| 303 | // so we cast it to unsigned to follow the standard. |
| 304 | D=(uint)D<<3; |
| 305 | |
| 306 | V->Dif[0]+=abs(D); |
| 307 | V->Dif[1]+=abs(D-V->D1); |
| 308 | V->Dif[2]+=abs(D+V->D1); |
| 309 | V->Dif[3]+=abs(D-V->D2); |
| 310 | V->Dif[4]+=abs(D+V->D2); |
| 311 | V->Dif[5]+=abs(D-V->D3); |
| 312 | V->Dif[6]+=abs(D+V->D3); |
| 313 | V->Dif[7]+=abs(D-V->D4); |
| 314 | V->Dif[8]+=abs(D+V->D4); |
| 315 | V->Dif[9]+=abs(D-UnpChannelDelta); |
| 316 | V->Dif[10]+=abs(D+UnpChannelDelta); |
| 317 | |
| 318 | UnpChannelDelta=V->LastDelta=(signed char)(Ch-V->LastChar); |
| 319 | V->LastChar=Ch; |
| 320 | |
| 321 | if ((V->ByteCount & 0x1F)==0) |
| 322 | { |
| 323 | uint MinDif=V->Dif[0],NumMinDif=0; |
| 324 | V->Dif[0]=0; |
| 325 | for (uint I=1;I<ASIZE(V->Dif);I++) |
| 326 | { |
| 327 | if (V->Dif[I]<MinDif) |
| 328 | { |
| 329 | MinDif=V->Dif[I]; |
| 330 | NumMinDif=I; |
| 331 | } |
| 332 | V->Dif[I]=0; |
| 333 | } |
| 334 | switch(NumMinDif) |
| 335 | { |
| 336 | case 1: |
| 337 | if (V->K1>=-16) |
| 338 | V->K1--; |
| 339 | break; |
| 340 | case 2: |
| 341 | if (V->K1<16) |
| 342 | V->K1++; |
| 343 | break; |
| 344 | case 3: |
| 345 | if (V->K2>=-16) |
nothing calls this directly
no outgoing calls
no test coverage detected