The interesting thing is that advanced encoders might create JPEGs that produce odd results with this decoder.

Yes, this is definitely an interesting question. Earlier this year I implemented a version of trellis quantization for some compression experiments that I've been tinkering with in my spare time. My code considers more possibilities than just rounding to the nearest quantization step when it deems that the bit rate savings in after entropy encoding may be worth the additional image loss (e.g., it might even completely zero a coefficient). That would violate this decoder's assumption that the original DCT coefficient must have been within a limited range around the quantization step.

I know that mozjpeg [1] features trellis quantization for JPEG encoding. I wonder how this decoder would do with that?

[1] https://github.com/mozilla/mozjpeg