FA-79036 / Image orientation metadata / Open access
Mirror removal negates the y-axis column · case 01
Mirrored front-camera clips report the wrong rotation.
ROOT CAUSE
Undoing the left-right mirror must negate the image of the x axis, but the code negates the y column.
VERIFIED REPAIR
Negate (a, b) when the determinant is negative before reading the rotation.
Unsuccessful approach: Swapping a and b is a transpose, not a mirror removal.
Case contract
Input [matrix, width, height] where matrix is the [a, b, c, d] part of a track display matrix stored as unsigned 32-bit 16.16 fixed-point words (x' = a*x + c*y, y' = b*x + d*y, screen y down). Only signed permutation matrices of unit entries are supported, otherwise "unsupported". A negative determinant means a left-right mirror applied before the rotation; the clockwise rotation is read from the image of the x axis after removing the mirror. Return rotate (0/90/180/270), mirror and the displayed [width, height].
Why this case matters
Camera, phone and scanner images carry an orientation hint separately from the stored pixels; galleries, thumbnailers, editors and upload pipelines must interpret it consistently or photos appear sideways, mirrored or doubly rotated.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
m, w, h = x
U = 65536
m = [v - (1 << 32) if v >= (1 << 31) else v for v in m]
a, b, c, d = m
if any(v not in (-U, 0, U) for v in m):
return 'unsupported'
if not ((b == 0 and c == 0 and a != 0 and d != 0) or (a == 0 and d == 0 and b != 0 and c != 0)):
return 'unsupported'
det = (a * d - b * c) // (U * U)
mirror = det == -1
if mirror:
c, d = -c, -d
deg = {(U, 0): 0, (0, U): 90, (-U, 0): 180, (0, -U): 270}[(a, b)]
if deg in (90, 270):
w, h = h, w
return {'rotate': deg, 'mirror': mirror, 'display': [w, h]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[0, 4294901760, 4294901760, 0], 760, 3281], {'rotate': 90, 'mirror': True, 'display': [3281, 760]}], [[[4294901760, 0, 0, 65536], 3623, 1679], {'rotate': 0, 'mirror': True, 'display': [3623, 1679]}], [[[4294901760, 0, 65536, 4294901760], 3830, 2696], 'unsupported'], [[[0, 65536, 4294901760, 65536], 559, 2713], 'unsupported'], [[[0, 65536, 4294901760, 65536], 1463, 780], 'unsupported'], [[[65536, 4294901760, 65536, 65536], 2751, 608], 'unsupported'], [[[0, 0, 4294901760, 0], 1243, 3391], 'unsupported'], [[[65536, 0, 0, 4294901760], 3304, 252], {'rotate': 180, 'mirror': True, 'display': [3304, 252]}]], [[[[0, 65536, 65536, 0], 1609, 1135], {'rotate': 270, 'mirror': True, 'display': [1135, 1609]}], [[[4294901760, 0, 0, 65536], 2607, 2935], {'rotate': 0, 'mirror': True, 'display': [2607, 2935]}], [[[4294901760, 0, 4294901760, 4294901760], 2730, 1220], 'unsupported'], [[[65536, 4294901760, 0, 4294901760], 3622, 60], 'unsupported'], [[[0, 4294901760, 65536, 65536], 1290, 2847], 'unsupported'], [[[65536, 0, 4294901760, 65536], 1369, 1577], 'unsupported'], [[[0, 4294901760, 65536, 0], 1556, 1750], {'rotate': 270, 'mirror': False, 'display': [1750, 1556]}], [[[4294901760, 0, 0, 65536], 2552, 3331], {'rotate': 0, 'mirror': True, 'display': [2552, 3331]}]], [[[[0, 65536, 65536, 0], 967, 3689], {'rotate': 270, 'mirror': True, 'display': [3689, 967]}], [[[0, 4294901760, 4294901760, 0], 251, 651], {'rotate': 90, 'mirror': True, 'display': [651, 251]}], [[[4294901760, 0, 65536, 0], 3442, 2421], 'unsupported'], [[[4294901760, 65536, 4294901760, 0], 392, 1027], 'unsupported'], [[[4294901760, 0, 4294901760, 65536], 1363, 2590], 'unsupported'], [[[4294901760, 0, 65536, 0], 3783, 1537], 'unsupported'], [[[0, 0, 0, 65536], 714, 1938], 'unsupported'], [[[4294901760, 0, 0, 65536], 3751, 979], {'rotate': 0, 'mirror': True, 'display': [3751, 979]}]], [[[[0, 65536, 65536, 0], 2244, 3320], {'rotate': 270, 'mirror': True, 'display': [3320, 2244]}], [[[4294901760, 0, 0, 65536], 1021, 3478], {'rotate': 0, 'mirror': True, 'display': [1021, 3478]}], [[[0, 0, 46341, 0], 991, 438], 'unsupported'], [[[65536, 0, 65536, 65536], 1287, 3950], 'unsupported'], [[[0, 65536, 0, 0], 2790, 437], 'unsupported'], [[[0, 4294901760, 65536, 4294901760], 3527, 100], 'unsupported'], [[[65536, 4294901760, 65536, 4294901760], 2961, 612], 'unsupported'], [[[65536, 0, 0, 4294901760], 2895, 2725], {'rotate': 180, 'mirror': True, 'display': [2895, 2725]}]], [[[[4294901760, 0, 0, 65536], 543, 1291], {'rotate': 0, 'mirror': True, 'display': [543, 1291]}], [[[0, 4294901760, 4294901760, 0], 1518, 2324], {'rotate': 90, 'mirror': True, 'display': [2324, 1518]}], [[[4294901760, 65536, 65536, 65536], 1654, 584], 'unsupported'], [[[4294901760, 65536, 65536, 0], 1703, 3849], 'unsupported'], [[[65536, 4294901760, 4294901760, 4294901760], 132, 2157], 'unsupported'], [[[0, 4294901760, 0, 0], 3596, 3944], 'unsupported'], [[[4294901760, 32768, 32768, 4294901760], 1623, 1094], 'unsupported'], [[[65536, 0, 0, 4294901760], 1985, 3076], {'rotate': 180, 'mirror': True, 'display': [1985, 3076]}]]]
labels = ["regression: mirror removal column", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: mirror removal column 0 | {'display': [3281, 760], 'mirror': True, 'rotate': 270} | {'display': [3281, 760], 'mirror': True, 'rotate': 90} | Failed |
| repair trap 1 | {'display': [3623, 1679], 'mirror': True, 'rotate': 180} | {'display': [3623, 1679], 'mirror': True, 'rotate': 0} | Failed |
| combined fault 2 | unsupported | unsupported | Passed |
| control 3 | unsupported | unsupported | Passed |
| control 4 | unsupported | unsupported | Passed |
| boundary 5 | unsupported | unsupported | Passed |
| boundary 6 | unsupported | unsupported | Passed |
| control 7 | {'display': [3304, 252], 'mirror': True, 'rotate': 0} | {'display': [3304, 252], 'mirror': True, 'rotate': 180} | Failed |
SHA-256 / 0ddc76294bc75fde6adcf0ff287a0d338a437bd095fd4c1024f415a95ce50dc3
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
m, w, h = x
U = 65536
m = [v - (1 << 32) if v >= (1 << 31) else v for v in m]
a, b, c, d = m
if any(v not in (-U, 0, U) for v in m):
return 'unsupported'
if not ((b == 0 and c == 0 and a != 0 and d != 0) or (a == 0 and d == 0 and b != 0 and c != 0)):
return 'unsupported'
det = (a * d - b * c) // (U * U)
mirror = det == -1
if mirror:
a, b = b, a
deg = {(U, 0): 0, (0, U): 90, (-U, 0): 180, (0, -U): 270}[(a, b)]
if deg in (90, 270):
w, h = h, w
return {'rotate': deg, 'mirror': mirror, 'display': [w, h]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[0, 4294901760, 4294901760, 0], 760, 3281], {'rotate': 90, 'mirror': True, 'display': [3281, 760]}], [[[4294901760, 0, 0, 65536], 3623, 1679], {'rotate': 0, 'mirror': True, 'display': [3623, 1679]}], [[[4294901760, 0, 65536, 4294901760], 3830, 2696], 'unsupported'], [[[0, 65536, 4294901760, 65536], 559, 2713], 'unsupported'], [[[0, 65536, 4294901760, 65536], 1463, 780], 'unsupported'], [[[65536, 4294901760, 65536, 65536], 2751, 608], 'unsupported'], [[[0, 0, 4294901760, 0], 1243, 3391], 'unsupported'], [[[65536, 0, 0, 4294901760], 3304, 252], {'rotate': 180, 'mirror': True, 'display': [3304, 252]}]], [[[[0, 65536, 65536, 0], 1609, 1135], {'rotate': 270, 'mirror': True, 'display': [1135, 1609]}], [[[4294901760, 0, 0, 65536], 2607, 2935], {'rotate': 0, 'mirror': True, 'display': [2607, 2935]}], [[[4294901760, 0, 4294901760, 4294901760], 2730, 1220], 'unsupported'], [[[65536, 4294901760, 0, 4294901760], 3622, 60], 'unsupported'], [[[0, 4294901760, 65536, 65536], 1290, 2847], 'unsupported'], [[[65536, 0, 4294901760, 65536], 1369, 1577], 'unsupported'], [[[0, 4294901760, 65536, 0], 1556, 1750], {'rotate': 270, 'mirror': False, 'display': [1750, 1556]}], [[[4294901760, 0, 0, 65536], 2552, 3331], {'rotate': 0, 'mirror': True, 'display': [2552, 3331]}]], [[[[0, 65536, 65536, 0], 967, 3689], {'rotate': 270, 'mirror': True, 'display': [3689, 967]}], [[[0, 4294901760, 4294901760, 0], 251, 651], {'rotate': 90, 'mirror': True, 'display': [651, 251]}], [[[4294901760, 0, 65536, 0], 3442, 2421], 'unsupported'], [[[4294901760, 65536, 4294901760, 0], 392, 1027], 'unsupported'], [[[4294901760, 0, 4294901760, 65536], 1363, 2590], 'unsupported'], [[[4294901760, 0, 65536, 0], 3783, 1537], 'unsupported'], [[[0, 0, 0, 65536], 714, 1938], 'unsupported'], [[[4294901760, 0, 0, 65536], 3751, 979], {'rotate': 0, 'mirror': True, 'display': [3751, 979]}]], [[[[0, 65536, 65536, 0], 2244, 3320], {'rotate': 270, 'mirror': True, 'display': [3320, 2244]}], [[[4294901760, 0, 0, 65536], 1021, 3478], {'rotate': 0, 'mirror': True, 'display': [1021, 3478]}], [[[0, 0, 46341, 0], 991, 438], 'unsupported'], [[[65536, 0, 65536, 65536], 1287, 3950], 'unsupported'], [[[0, 65536, 0, 0], 2790, 437], 'unsupported'], [[[0, 4294901760, 65536, 4294901760], 3527, 100], 'unsupported'], [[[65536, 4294901760, 65536, 4294901760], 2961, 612], 'unsupported'], [[[65536, 0, 0, 4294901760], 2895, 2725], {'rotate': 180, 'mirror': True, 'display': [2895, 2725]}]], [[[[4294901760, 0, 0, 65536], 543, 1291], {'rotate': 0, 'mirror': True, 'display': [543, 1291]}], [[[0, 4294901760, 4294901760, 0], 1518, 2324], {'rotate': 90, 'mirror': True, 'display': [2324, 1518]}], [[[4294901760, 65536, 65536, 65536], 1654, 584], 'unsupported'], [[[4294901760, 65536, 65536, 0], 1703, 3849], 'unsupported'], [[[65536, 4294901760, 4294901760, 4294901760], 132, 2157], 'unsupported'], [[[0, 4294901760, 0, 0], 3596, 3944], 'unsupported'], [[[4294901760, 32768, 32768, 4294901760], 1623, 1094], 'unsupported'], [[[65536, 0, 0, 4294901760], 1985, 3076], {'rotate': 180, 'mirror': True, 'display': [1985, 3076]}]]]
labels = ["regression: mirror removal column", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: mirror removal column 0 | {'display': [760, 3281], 'mirror': True, 'rotate': 180} | {'display': [3281, 760], 'mirror': True, 'rotate': 90} | Failed |
| repair trap 1 | {'display': [1679, 3623], 'mirror': True, 'rotate': 270} | {'display': [3623, 1679], 'mirror': True, 'rotate': 0} | Failed |
| combined fault 2 | unsupported | unsupported | Passed |
| control 3 | unsupported | unsupported | Passed |
| control 4 | unsupported | unsupported | Passed |
| boundary 5 | unsupported | unsupported | Passed |
| boundary 6 | unsupported | unsupported | Passed |
| control 7 | {'display': [252, 3304], 'mirror': True, 'rotate': 90} | {'display': [3304, 252], 'mirror': True, 'rotate': 180} | Failed |
SHA-256 / ab6a361c979dace78f0b1e42e18f700a799e24928061b24bb9d06c0ad19c0df7
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
m, w, h = x
U = 65536
m = [v - (1 << 32) if v >= (1 << 31) else v for v in m]
a, b, c, d = m
if any(v not in (-U, 0, U) for v in m):
return 'unsupported'
if not ((b == 0 and c == 0 and a != 0 and d != 0) or (a == 0 and d == 0 and b != 0 and c != 0)):
return 'unsupported'
det = (a * d - b * c) // (U * U)
mirror = det == -1
if mirror:
a, b = -a, -b
deg = {(U, 0): 0, (0, U): 90, (-U, 0): 180, (0, -U): 270}[(a, b)]
if deg in (90, 270):
w, h = h, w
return {'rotate': deg, 'mirror': mirror, 'display': [w, h]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[0, 4294901760, 4294901760, 0], 760, 3281], {'rotate': 90, 'mirror': True, 'display': [3281, 760]}], [[[4294901760, 0, 0, 65536], 3623, 1679], {'rotate': 0, 'mirror': True, 'display': [3623, 1679]}], [[[4294901760, 0, 65536, 4294901760], 3830, 2696], 'unsupported'], [[[0, 65536, 4294901760, 65536], 559, 2713], 'unsupported'], [[[0, 65536, 4294901760, 65536], 1463, 780], 'unsupported'], [[[65536, 4294901760, 65536, 65536], 2751, 608], 'unsupported'], [[[0, 0, 4294901760, 0], 1243, 3391], 'unsupported'], [[[65536, 0, 0, 4294901760], 3304, 252], {'rotate': 180, 'mirror': True, 'display': [3304, 252]}]], [[[[0, 65536, 65536, 0], 1609, 1135], {'rotate': 270, 'mirror': True, 'display': [1135, 1609]}], [[[4294901760, 0, 0, 65536], 2607, 2935], {'rotate': 0, 'mirror': True, 'display': [2607, 2935]}], [[[4294901760, 0, 4294901760, 4294901760], 2730, 1220], 'unsupported'], [[[65536, 4294901760, 0, 4294901760], 3622, 60], 'unsupported'], [[[0, 4294901760, 65536, 65536], 1290, 2847], 'unsupported'], [[[65536, 0, 4294901760, 65536], 1369, 1577], 'unsupported'], [[[0, 4294901760, 65536, 0], 1556, 1750], {'rotate': 270, 'mirror': False, 'display': [1750, 1556]}], [[[4294901760, 0, 0, 65536], 2552, 3331], {'rotate': 0, 'mirror': True, 'display': [2552, 3331]}]], [[[[0, 65536, 65536, 0], 967, 3689], {'rotate': 270, 'mirror': True, 'display': [3689, 967]}], [[[0, 4294901760, 4294901760, 0], 251, 651], {'rotate': 90, 'mirror': True, 'display': [651, 251]}], [[[4294901760, 0, 65536, 0], 3442, 2421], 'unsupported'], [[[4294901760, 65536, 4294901760, 0], 392, 1027], 'unsupported'], [[[4294901760, 0, 4294901760, 65536], 1363, 2590], 'unsupported'], [[[4294901760, 0, 65536, 0], 3783, 1537], 'unsupported'], [[[0, 0, 0, 65536], 714, 1938], 'unsupported'], [[[4294901760, 0, 0, 65536], 3751, 979], {'rotate': 0, 'mirror': True, 'display': [3751, 979]}]], [[[[0, 65536, 65536, 0], 2244, 3320], {'rotate': 270, 'mirror': True, 'display': [3320, 2244]}], [[[4294901760, 0, 0, 65536], 1021, 3478], {'rotate': 0, 'mirror': True, 'display': [1021, 3478]}], [[[0, 0, 46341, 0], 991, 438], 'unsupported'], [[[65536, 0, 65536, 65536], 1287, 3950], 'unsupported'], [[[0, 65536, 0, 0], 2790, 437], 'unsupported'], [[[0, 4294901760, 65536, 4294901760], 3527, 100], 'unsupported'], [[[65536, 4294901760, 65536, 4294901760], 2961, 612], 'unsupported'], [[[65536, 0, 0, 4294901760], 2895, 2725], {'rotate': 180, 'mirror': True, 'display': [2895, 2725]}]], [[[[4294901760, 0, 0, 65536], 543, 1291], {'rotate': 0, 'mirror': True, 'display': [543, 1291]}], [[[0, 4294901760, 4294901760, 0], 1518, 2324], {'rotate': 90, 'mirror': True, 'display': [2324, 1518]}], [[[4294901760, 65536, 65536, 65536], 1654, 584], 'unsupported'], [[[4294901760, 65536, 65536, 0], 1703, 3849], 'unsupported'], [[[65536, 4294901760, 4294901760, 4294901760], 132, 2157], 'unsupported'], [[[0, 4294901760, 0, 0], 3596, 3944], 'unsupported'], [[[4294901760, 32768, 32768, 4294901760], 1623, 1094], 'unsupported'], [[[65536, 0, 0, 4294901760], 1985, 3076], {'rotate': 180, 'mirror': True, 'display': [1985, 3076]}]]]
labels = ["regression: mirror removal column", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: mirror removal column 0 | {'display': [3281, 760], 'mirror': True, 'rotate': 90} | {'display': [3281, 760], 'mirror': True, 'rotate': 90} | Passed |
| repair trap 1 | {'display': [3623, 1679], 'mirror': True, 'rotate': 0} | {'display': [3623, 1679], 'mirror': True, 'rotate': 0} | Passed |
| combined fault 2 | unsupported | unsupported | Passed |
| control 3 | unsupported | unsupported | Passed |
| control 4 | unsupported | unsupported | Passed |
| boundary 5 | unsupported | unsupported | Passed |
| boundary 6 | unsupported | unsupported | Passed |
| control 7 | {'display': [3304, 252], 'mirror': True, 'rotate': 180} | {'display': [3304, 252], 'mirror': True, 'rotate': 180} | Passed |
SHA-256 / 9642459fd831c76040146f967427002409ce940ab730ac70969678ea819f066a
Verification & scope
A deterministic bounded teaching model with a stipulated contract; it makes no claim of conformance to any published specification. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:40.858781+00:00.
Case digest / 0ed01323dca65baf1d06c7bab3a39c2c251dfc29d5e59f828ca35134bde0071c