MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Similarity

Function Similarity

common/ReadbackSpinManager.cpp:23–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23static int Similarity(const std::vector<ReadbackSpinManager::Event>& a, std::vector<ReadbackSpinManager::Event>& b)
24{
25 u32 a_num_readbacks = std::count_if(a.begin(), a.end(), EventIsReadback);
26 u32 b_num_readbacks = std::count_if(b.begin(), b.end(), EventIsReadback);
27
28 int score = 0x10 - abs(static_cast<int>(a.size() - b.size()));
29
30 if (a_num_readbacks == b_num_readbacks)
31 score += 0x10000;
32
33 auto a_idx = a.begin();
34 auto b_idx = b.begin();
35 while (a_idx != a.end() && b_idx != b.end())
36 {
37 if (EventIsReadback(*a_idx) && EventIsReadback(*b_idx))
38 {
39 // Same number of events between readbacks
40 score += 0x1000;
41 }
42 // Try to match up on readbacks
43 else if (EventIsReadback(*a_idx))
44 {
45 b_idx++;
46 continue;
47 }
48 else if (EventIsReadback(*b_idx))
49 {
50 a_idx++;
51 continue;
52 }
53 else if (a_idx->size == b_idx->size)
54 {
55 // Same size
56 score += 0x100;
57 }
58 else if (a_idx->size / 2 <= b_idx->size && b_idx->size / 2 <= a_idx->size)
59 {
60 // Similar size
61 score += 0x10;
62 }
63 a_idx++;
64 b_idx++;
65 continue;
66 }
67 // Both hit the end at the same time
68 if (a_idx == a.end() && b_idx == b.end())
69 score += 0x1000;
70
71 return score;
72}
73
74static u32 PrevFrameNo(u32 frame, size_t total_frames)
75{

Callers 1

NextFrameMethod · 0.85

Calls 5

EventIsReadbackFunction · 0.85
absFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected