3 ms·
I solved this problem for my use case by using an approximate diff. Basically diffing took too long ( I was diffing to remove duplicate frames from a virtualiz
by graderjs 6y ago
I solved this problem for my use case by using an approximate diff.
Basically diffing took too long ( I was diffing to remove duplicate frames from a virtualized browser to browser screencast ), so after trying to various options (hashing, diffs, etc) I just went with a simple check of a basically random but fixed set of pixels, which worked really well. I don't have data on the actual false positives/ negatives but for the thing important in my case, perceptual difference and not sending the same frame twice (to save bandwidth and speed) it worked great, and was "constant time".
The "code" is here: https://github.com/c9fe/ViewFinder/blob/84620bd87abb32b2f2c3dc0b79a0be5212fa14ee/zombie-lord/screenShots.js#L9 https://github.com/c9fe/ViewFinder/blob/84620bd87abb32b2f2c3...
And a demo of the project is: https://demo.browsergap.dosyago.com https://demo.browsergap.dosyago.com (if you check it on Safari mobile you need to plant your clicks about half a finger under where you think they should go, some bug!)
I'd like to know some idea of how this posted fast diff works. I checked around the repo and couldn't figure it out, but it seems to be splitting across multiple cores, but still looping over each pixel (but divided by the number of cores). I thought it might be doing something like checking 64-bit blocks somehow, but seems not.
- filleokus 6y agoDid you try using any exotic wide instructions, like AVX or something?
- graderjs 6y agoNo I didn't and my case didn't need it, but I was thinking maybe that's what this posted fast diff did, but I took a quick look at the go code and couldn't figure out if it did or not. Edit on the above: it should say "fixed set of bytes" not "fixed set of pixels"