So I created this dumb diagram to illustrate a point. I apologize to all the pixel artists out there; I don't think it's very good.
Yeah, when I did that thing where I told FFmpeg to interpret image data as a raw video, push it it through video codecs, then decode it back to get the final result, this is quite literally what I meant. Of course, the resolutions used are a bit higher. I'm realizing that the resolution used for the intermediate "video" has quite a lot of bearing on the pattern of the distortion caused by this lossy encoding.
In this one, the intermediate video was 100x150. (The original image was 2000x3000; cropped for file size reasons).
.
Very strong, predictable horizontal blocking pattern. I'd call that macro-macroblocking.
Here's one where it was 149x211; both prime numbers (don't believe me?
The OEIS says as much)
Less predictable. It's noisier, but part of me still thinks there's some pattern to it. It's going from top-left to bottom-right.
Prime numbers can yield a discernible pattern, then. I'm wondering if there exists integers a and b, both equal to or greater than 128 (to keep the codecs happy), such that when used as input dimensions for this process, they produce the "noisiest" pattern.
This feels like a distant relative of the "optimal sunflower seed arrangement" problem, but I'm not sure why I'm saying that. There, it's concerned with packing the most seeds per area. Here, I'm trying to find the input values that yield the least "predictable" patterns.
There does exist the least elegant, brute-force method; just iterate over a and b between 128 and their respective maxima. I already know how that goes in Python:
for a in range(128, 2000):
for b in range(128, 3000):
inSize = str(a) + "x" + str(b)
which would be some 5 million possible resolutions and output images. Not feasible. Even if I limited the range to [128, 500], it'd still be a staggering 130 thousand.
I dunno, modular arithmetic? You want to find a and b such that a*b*x mod 2000 (x is the "frame number", 2000 is the image width) yields the longest possible period? But that's not even the case; f(x) = 149*211x mod 2000 still generates a 2000-long period (which is the longest possible?), yet produces a visible pattern of some kind. Maybe if you consider the simplest possible "encoder"? Odd frames black, even frames white?
I have no clue anymore.