There are a given number of Tetris block patterns. For each pattern, there are four variations: not rotated, rotated 90, rotated 180 and rotated 270 degrees.
Construct four arrays, one for each rotation. Each array will contain pointers to all patterns for a given rotation.
If I understand your problem correctly, there is no need for approximate matching. You want to see if a given candidate block image matches any of the Tetris blocks in any way. So, the comparison can be done using the trusty xor.
The code below shows the comparison function for unrotated patterns. Clearly, I did not type in all the patterns (although I found http://www.colinfahey.com/tetris/tetris_diagram_pieces_orientations_new.jpg via Google). That part is up to you.
The multi-threaded version of this program would have separate functions for comparing rotated versions accessing four separate arrays of patterns.
#include <stdio.h>
#define DIM 5
unsigned char blocks[][DIM] = {
{ 0x00, 0x00, 0x04, 0x0e, 0x00, },
{ 0x10, 0x10, 0x10, 0x10, 0x10, },
};
int compare_block(
unsigned char src[DIM],
unsigned char candidate[DIM] ) {
int i;
int result = 0;
for ( i = 0; i < DIM; ++i ) {
result += src[i] ^ candidate[i];
}
return !result;
}
int main(void) {
int i;
unsigned char candidate[] = { 0x00, 0x00, 0x04, 0x0e, 0x00, };
for ( i = 0; i < sizeof blocks/sizeof blocks[0]; ++i ) {
int result = compare_block(blocks[i], candidate);
printf("Candidate %s block %d\n",
(result ? "matched" : "did not match"),
i
);
}
return 0;
}