MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / UpdateECC

Method UpdateECC

Libraries/unrar/rs16.cpp:261–311  ·  view source on GitHub ↗

We update ECC in blocks by applying every data block to all ECC blocks. This function applies one data block to one ECC block.

Source from the content-addressed store, hash-verified

259// We update ECC in blocks by applying every data block to all ECC blocks.
260// This function applies one data block to one ECC block.
261void RSCoder16::UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize)
262{
263 if (DataNum==0) // Init ECC data.
264 memset(ECC, 0, BlockSize);
265
266 bool DirectAccess;
267#ifdef LITTLE_ENDIAN
268 // We can access data and ECC directly if we have little endian 16 bit uint.
269 DirectAccess=sizeof(ushort)==2;
270#else
271 DirectAccess=false;
272#endif
273
274#ifdef USE_SSE
275 if (DirectAccess && SSE_UpdateECC(DataNum,ECCNum,Data,ECC,BlockSize))
276 return;
277#endif
278
279 if (ECCNum==0)
280 {
281 if (DataLogSize!=BlockSize)
282 {
283 delete[] DataLog;
284 DataLog=new uint[BlockSize];
285 DataLogSize=BlockSize;
286
287 }
288 if (DirectAccess)
289 for (size_t I=0; I<BlockSize; I+=2)
290 DataLog[I] = gfLog[ *(ushort*)(Data+I) ];
291 else
292 for (size_t I=0; I<BlockSize; I+=2)
293 {
294 uint D=Data[I]+Data[I+1]*256;
295 DataLog[I] = gfLog[ D ];
296 }
297 }
298
299 uint ML = gfLog[ MX[ECCNum * ND + DataNum] ];
300
301 if (DirectAccess)
302 for (size_t I=0; I<BlockSize; I+=2)
303 *(ushort*)(ECC+I) ^= gfExp[ ML + DataLog[I] ];
304 else
305 for (size_t I=0; I<BlockSize; I+=2)
306 {
307 uint R=gfExp[ ML + DataLog[I] ];
308 ECC[I]^=byte(R);
309 ECC[I+1]^=byte(R/256);
310 }
311}
312
313
314#ifdef USE_SSE

Callers 1

ProcessAreaRSMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected