This code compares intensities of two pixel pairs and verifies that the difference is within the threshold: | PixelA1-PixelB1 | < MaxDiff and | PixelA2-PixelB2 | < MaxDiff Each pixel has 32 bits: U - 8-bit (higher order) chroma 1 (ignored) V - 8-bit chroma 2 (ignored) 0 - 8-bit empty Y - 8-bit (lower order) luma, unsigned MaxDiff: 7FFFxxxx7FFFxxxx where xxxx - is a 16-bit threshold (MaxDiff) movq mm0, PixelA ; PixelA1 PixelA2 movq mm1, PixelB ; PixelB1 PixelB2 movq mm2, mm0 ; movq mm3, mm1 psubusw mm0, mm1 ; Delta = difference between pixel intensities psubusw mm3, mm2 paddusw mm0, mm3 pcmpgtw mm0, MaxDiff ; abs(Delta)>MaxDiff ? packsswb mm0, mm0 ; FFFF => larger than MaxDiff movd ecx, mm0 jecxz Both_pixel_pairs_are_within_MaxDiff