---------------------------------------------------------------------------
| 5476 | |
| 5477 | //--------------------------------------------------------------------------- |
| 5478 | void File_Mk::CRC32_Check () |
| 5479 | { |
| 5480 | for (size_t i = 0; i<CRC32Compute.size(); i++) |
| 5481 | if (CRC32Compute[i].UpTo && File_Offset + Buffer_Offset - (size_t)Header_Size >= CRC32Compute[i].From) |
| 5482 | { |
| 5483 | //Handling of case when data is not completetely loaded because it is not needed by the parser |
| 5484 | const size_t Offset = Buffer_Offset + (size_t)((Element_WantNextLevel && Element_Offset <= Element_Size) ? Element_Offset : Element_Size); |
| 5485 | if (Element_Offset > Element_Size) |
| 5486 | { |
| 5487 | if (Config->ParseSpeed<1) |
| 5488 | { |
| 5489 | CRC32Compute.clear(); |
| 5490 | break; |
| 5491 | } |
| 5492 | CRC32Compute_SkipUpTo = File_Offset + Buffer_Offset + Element_Offset; |
| 5493 | Element_Offset = Element_Size; |
| 5494 | Element_ThisIsAList(); // Fake for forcing the parser to be called for the whole stream |
| 5495 | } |
| 5496 | |
| 5497 | Matroska_CRC32_Compute(CRC32Compute[i].Computed, Buffer + Buffer_Offset - (size_t)Header_Size, Buffer + Offset); |
| 5498 | if (File_Offset + Offset >= CRC32Compute[i].UpTo) |
| 5499 | { |
| 5500 | CRC32Compute[i].Computed ^= 0xFFFFFFFF; |
| 5501 | |
| 5502 | #if MEDIAINFO_TRACE |
| 5503 | if (Trace_Activated) |
| 5504 | { |
| 5505 | //Searching and replacing CRC-32 information |
| 5506 | //TODO: better implementation without this ugly hack |
| 5507 | |
| 5508 | element_details::Element_Node *node = Get_Trace_Node(i); |
| 5509 | if (node) |
| 5510 | { |
| 5511 | std::string ToSearchInInfo=std::string("Not tested ")+Ztring::ToZtring(i).To_UTF8()+' '+Ztring::ToZtring(CRC32Compute[i].Expected).To_UTF8(); |
| 5512 | CRC32_Check_In_Node(ToSearchInInfo, CRC32Compute[i].Computed == CRC32Compute[i].Expected?"OK":"NOK", node); |
| 5513 | |
| 5514 | #if MEDIAINFO_FIXITY |
| 5515 | if (Config->TryToFix_Get() && CRC32Compute[i].Computed!=CRC32Compute[i].Expected) |
| 5516 | { |
| 5517 | size_t NewBuffer_Size=(size_t)(CRC32Compute[i].UpTo-CRC32Compute[i].From); |
| 5518 | File F; |
| 5519 | if (F.Open(File_Name)) |
| 5520 | { |
| 5521 | int8u* NewBuffer = new int8u[NewBuffer_Size]; |
| 5522 | F.GoTo(CRC32Compute[i].From); |
| 5523 | F.Read(NewBuffer, NewBuffer_Size); |
| 5524 | int8u Modified=0; |
| 5525 | size_t BitPosition=Matroska_TryToFixCRC(NewBuffer, NewBuffer_Size, CRC32Compute[i].Expected, Modified); |
| 5526 | if (BitPosition!=(size_t)-1) |
| 5527 | { |
| 5528 | size_t BytePosition=BitPosition>>3; |
| 5529 | size_t BitInBytePosition=BitPosition&0x7; |
| 5530 | Modified^=1<<BitInBytePosition; |
| 5531 | FixFile(CRC32Compute[i].From+BytePosition, &Modified, 1)?Param_Info1("Fixed"):Param_Info1("Not fixed"); |
| 5532 | } |
| 5533 | delete[] NewBuffer; //NewBuffer=NULL; |
| 5534 | } |
| 5535 | } |
nothing calls this directly
no test coverage detected