{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:mrps:metadata:mr-phase-shift-snapshot:v4:doc1",
  "title": "MRPS v4 adaptive mono/stereo snapshot metadata",
  "description": "Machine-readable contract for metadata emitted by quest_3_mr_phase_shift_encoder_adaptive_v4.html. Descriptions are normative together with MRPS_v4_SPEC.md.",
  "type": "object",
  "properties": {
    "schema": {
      "type": "string",
      "description": "MRPS format identifier.",
      "const": "mr-phase-shift-snapshot/v4"
    },
    "captureId": {
      "type": "string",
      "description": "Unique capture identifier paired across PNG and sidecar JSON."
    },
    "capturedAt": {
      "type": "string",
      "description": "ISO-8601 wall-clock capture/export time.",
      "format": "date-time"
    },
    "files": {
      "type": "object",
      "description": "File names and PNG metadata embedding contract.",
      "properties": {
        "imageFilename": {
          "type": "string",
          "description": "Suggested PNG filename."
        },
        "jsonFilename": {
          "type": "string",
          "description": "Suggested sidecar JSON filename."
        },
        "pngMetadata": {
          "type": "object",
          "description": "Location and encoding of embedded JSON in PNG.",
          "properties": {
            "chunkType": {
              "type": "string",
              "description": "PNG text chunk type.",
              "const": "iTXt"
            },
            "keyword": {
              "type": "string",
              "description": "iTXt keyword used to locate MRPS JSON.",
              "const": "mr-phase-shift-metadata"
            },
            "compression": {
              "type": "string",
              "description": "iTXt compression mode.",
              "const": "none"
            }
          },
          "required": [
            "chunkType",
            "keyword",
            "compression"
          ],
          "additionalProperties": true
        },
        "imageIsSelfContained": {
          "type": "boolean",
          "description": "True when JSON and all native depth payloads are embedded in the PNG."
        }
      },
      "required": [
        "imageFilename",
        "jsonFilename",
        "pngMetadata",
        "imageIsSelfContained"
      ],
      "additionalProperties": true
    },
    "assumptions": {
      "type": "object",
      "description": "Explicit RGB-to-depth calibration assumptions.",
      "properties": {
        "rgbCameraUsesExactDepthSensorFieldOfView": {
          "type": "boolean",
          "description": "Treat RGB FOV as identical to its associated depth sensor."
        },
        "rgbCameraUsesExactDepthSensorOpticalAxis": {
          "type": "boolean",
          "description": "Treat RGB optical axis as identical to depth sensor."
        },
        "rgbCameraUsesExactDepthSensorDistortionModel": {
          "type": "boolean",
          "description": "Treat RGB distortion as identical to depth sensor."
        },
        "note": {
          "type": "string",
          "description": "Human-readable statement of the assumption."
        }
      },
      "required": [
        "rgbCameraUsesExactDepthSensorFieldOfView",
        "rgbCameraUsesExactDepthSensorOpticalAxis",
        "rgbCameraUsesExactDepthSensorDistortionModel",
        "note"
      ],
      "additionalProperties": true
    },
    "coordinateSystem": {
      "type": "object",
      "description": "Physical units, axes, origin, clip-space, and matrix conventions.",
      "properties": {
        "units": {
          "type": "string",
          "description": "Physical coordinate unit.",
          "const": "meters"
        },
        "handedness": {
          "type": "string",
          "description": "Coordinate handedness.",
          "const": "right-handed"
        },
        "axes": {
          "type": "string",
          "description": "Axis direction convention."
        },
        "origin": {
          "type": "string",
          "description": "Capture-local origin definition."
        },
        "worldAlignmentRequired": {
          "type": "boolean",
          "description": "False; capture attaches to playback camera origin."
        },
        "matrixStorage": {
          "type": "string",
          "description": "Matrix memory ordering.",
          "const": "column-major"
        },
        "vectorConvention": {
          "type": "string",
          "description": "Column-vector and AFromB naming convention."
        },
        "clipSpace": {
          "type": "string",
          "description": "WebGL NDC clip-space convention."
        }
      },
      "required": [
        "units",
        "handedness",
        "axes",
        "origin",
        "worldAlignmentRequired",
        "matrixStorage",
        "vectorConvention",
        "clipSpace"
      ],
      "additionalProperties": true
    },
    "source": {
      "type": "object",
      "description": "Capture API and reference-space provenance.",
      "properties": {
        "xrSessionMode": {
          "type": "string",
          "description": "XR session mode."
        },
        "rgbApi": {
          "type": "string",
          "description": "RGB capture API."
        },
        "depthApi": {
          "type": "string",
          "description": "Depth capture API."
        },
        "referenceSpaceType": {
          "type": "string",
          "description": "Reference space used to obtain capture pose."
        }
      },
      "required": [
        "xrSessionMode",
        "rgbApi",
        "depthApi",
        "referenceSpaceType"
      ],
      "additionalProperties": true
    },
    "captureTrigger": {
      "anyOf": [
        {
          "$ref": "#/$defs/captureTrigger"
        },
        {
          "type": "null"
        }
      ],
      "description": "Action that requested the snapshot; diagnostic only."
    },
    "viewConfiguration": {
      "type": "object",
      "description": "Accepted XR view mode and stereo baseline diagnostics.",
      "properties": {
        "mode": {
          "type": "string",
          "description": "Capture mode.",
          "enum": [
            "mono",
            "stereo"
          ]
        },
        "primaryViewCount": {
          "type": "integer",
          "description": "Accepted primary XR view count.",
          "enum": [
            1,
            2
          ]
        },
        "eyeOrder": {
          "type": "array",
          "description": "XR eye labels in output order.",
          "items": {
            "type": "string"
          }
        },
        "viewIds": {
          "type": "array",
          "description": "Stable MRPS view IDs in output order.",
          "items": {
            "type": "string"
          }
        },
        "supportsPlaybackOnDifferentViewConfiguration": {
          "type": "boolean",
          "description": "True because metric capture-local geometry is reprojected with playback views."
        },
        "stereoBaseline": {
          "anyOf": [
            {
              "$ref": "#/$defs/baseline"
            },
            {
              "type": "null"
            }
          ],
          "description": "Stereo capture baseline diagnostics, null for mono."
        }
      },
      "required": [
        "mode",
        "primaryViewCount",
        "eyeOrder",
        "viewIds",
        "supportsPlaybackOnDifferentViewConfiguration",
        "stereoBaseline"
      ],
      "additionalProperties": true
    },
    "timing": {
      "type": "object",
      "description": "Best-effort RGB/depth frame-pairing timestamps.",
      "properties": {
        "synchronizationMethod": {
          "type": "string",
          "description": "Capture ordering/strategy."
        },
        "hardwareSynchronized": {
          "type": "boolean",
          "description": "Whether hardware synchronization is claimed."
        },
        "video": {
          "type": "object",
          "description": "RGB frame-capture timing and browser callback metadata.",
          "properties": {
            "mode": {
              "type": "string",
              "description": "Video frame capture path."
            },
            "requestedAtPerformanceMs": {
              "type": "number",
              "description": "performance.now() timestamp when RGB capture was requested."
            },
            "frameCallbackAtPerformanceMs": {
              "type": "number",
              "description": "Video callback/fallback timestamp used for skew estimation."
            },
            "copiedAtPerformanceMs": {
              "type": "number",
              "description": "Timestamp after RGB image copy completed."
            },
            "metadata": {
              "anyOf": [
                {
                  "type": "object",
                  "description": "Sanitized requestVideoFrameCallback metadata; all fields are optional numbers.",
                  "properties": {
                    "presentationTime": {
                      "type": "number",
                      "description": "Presentation time."
                    },
                    "expectedDisplayTime": {
                      "type": "number",
                      "description": "Expected display time."
                    },
                    "width": {
                      "type": "number",
                      "description": "Presented frame width."
                    },
                    "height": {
                      "type": "number",
                      "description": "Presented frame height."
                    },
                    "mediaTime": {
                      "type": "number",
                      "description": "Media timeline time."
                    },
                    "presentedFrames": {
                      "type": "number",
                      "description": "Presented frame count."
                    },
                    "processingDuration": {
                      "type": "number",
                      "description": "Processing duration."
                    },
                    "captureTime": {
                      "type": "number",
                      "description": "Estimated capture time."
                    },
                    "receiveTime": {
                      "type": "number",
                      "description": "Receive time."
                    },
                    "rtpTimestamp": {
                      "type": "number",
                      "description": "RTP timestamp."
                    }
                  },
                  "additionalProperties": true
                },
                {
                  "type": "null"
                }
              ],
              "description": "Sanitized browser video-frame metadata, or null."
            }
          },
          "required": [],
          "additionalProperties": true
        },
        "xrFrameTimePerformanceMs": {
          "type": "number",
          "description": "XR animation-frame timestamp in performance timebase."
        },
        "estimatedVideoToDepthSkewMs": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "XR timestamp minus RGB frame callback timestamp; null if unavailable."
        }
      },
      "required": [
        "synchronizationMethod",
        "hardwareSynchronized",
        "video",
        "xrFrameTimePerformanceMs",
        "estimatedVideoToDepthSkewMs"
      ],
      "additionalProperties": true
    },
    "output": {
      "type": "object",
      "description": "Visible atlas dimensions and quadrant placement.",
      "properties": {
        "width": {
          "type": "integer",
          "description": "Full PNG width.",
          "const": 2048
        },
        "height": {
          "type": "integer",
          "description": "Full PNG height.",
          "const": 2048
        },
        "topLeft": {
          "$ref": "#/$defs/quadrant"
        },
        "topRight": {
          "$ref": "#/$defs/quadrant"
        },
        "bottomLeft": {
          "$ref": "#/$defs/quadrant"
        },
        "bottomRight": {
          "$ref": "#/$defs/quadrant"
        },
        "depthTileSize": {
          "type": "integer",
          "description": "Logical square size of each phase tile.",
          "const": 512
        }
      },
      "required": [
        "width",
        "height",
        "topLeft",
        "topRight",
        "bottomLeft",
        "bottomRight",
        "depthTileSize"
      ],
      "additionalProperties": true
    },
    "rgb": {
      "type": "object",
      "description": "RGB source dimensions/layout, aspect mapping, and track diagnostics.",
      "properties": {
        "sourceWidth": {
          "type": "integer",
          "description": "Captured RGB source width.",
          "minimum": 1
        },
        "sourceHeight": {
          "type": "integer",
          "description": "Captured RGB source height.",
          "minimum": 1
        },
        "sourceAspect": {
          "type": "number",
          "description": "Source width divided by source height."
        },
        "mediaStreamVideoTrackCount": {
          "type": "integer",
          "description": "Number of video tracks, not physical camera count.",
          "minimum": 0
        },
        "physicalCameraCount": {
          "type": "null",
          "description": "Deliberately unknown physical camera/lens count."
        },
        "physicalCameraCountReason": {
          "type": "string",
          "description": "Why physical camera count is not inferred."
        },
        "selectedLayout": {
          "type": "string",
          "description": "User/UI layout selection.",
          "enum": [
            "auto",
            "mono",
            "sbs"
          ]
        },
        "resolvedLayout": {
          "type": "string",
          "description": "Actual source frame interpretation.",
          "enum": [
            "mono",
            "sbs"
          ]
        },
        "fitMode": {
          "type": "string",
          "description": "Aspect mapping policy.",
          "enum": [
            "contain",
            "cover"
          ]
        },
        "trackSettings": {
          "anyOf": [
            {
              "type": "object",
              "description": "Pass-through MediaStreamTrack settings; diagnostic, not intrinsic calibration.",
              "properties": {
                "width": {
                  "type": "integer",
                  "description": "Track output width."
                },
                "height": {
                  "type": "integer",
                  "description": "Track output height."
                },
                "aspectRatio": {
                  "type": "number",
                  "description": "Track output aspect ratio."
                },
                "frameRate": {
                  "type": "number",
                  "description": "Track frame rate."
                },
                "facingMode": {
                  "type": "string",
                  "description": "Facing mode."
                },
                "resizeMode": {
                  "type": "string",
                  "description": "Resize mode."
                },
                "deviceId": {
                  "type": "string",
                  "description": "Permission-scoped source device ID."
                },
                "groupId": {
                  "type": "string",
                  "description": "Permission-scoped group ID."
                }
              },
              "additionalProperties": true
            },
            {
              "type": "null"
            }
          ],
          "description": "MediaStreamTrack.getSettings() snapshot."
        },
        "mappings": {
          "type": "object",
          "description": "Aspect/crop mapping keyed by mono or left/right view.",
          "properties": {
            "mono": {
              "$ref": "#/$defs/mapping"
            },
            "left": {
              "$ref": "#/$defs/mapping"
            },
            "right": {
              "$ref": "#/$defs/mapping"
            }
          },
          "minProperties": 1,
          "additionalProperties": true
        },
        "calibrationSource": {
          "type": "string",
          "description": "States that depth sensor geometry calibrates assigned RGB under explicit assumption."
        }
      },
      "required": [
        "sourceWidth",
        "sourceHeight",
        "sourceAspect",
        "mediaStreamVideoTrackCount",
        "physicalCameraCount",
        "physicalCameraCountReason",
        "selectedLayout",
        "resolvedLayout",
        "fitMode",
        "trackSettings",
        "mappings",
        "calibrationSource"
      ],
      "additionalProperties": true
    },
    "depthSession": {
      "type": "object",
      "description": "Granted/requested WebXR depth session configuration.",
      "properties": {
        "usage": {
          "type": "string",
          "description": "Granted depth usage, normally cpu-optimized."
        },
        "dataFormat": {
          "type": "string",
          "description": "Granted depth format."
        },
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Granted raw/smooth type when exposed."
        },
        "matchDepthViewRequested": {
          "type": "boolean",
          "description": "Whether session request asked the runtime to match depth to XR views."
        }
      },
      "required": [
        "usage",
        "dataFormat"
      ],
      "additionalProperties": true
    },
    "metricDepth": {
      "type": "object",
      "description": "Canonical manifest for authoritative native metric depth payloads.",
      "properties": {
        "preferredSource": {
          "type": "string",
          "description": "Declares native embedded chunks as preferred."
        },
        "exactDeviceSamplesPreserved": {
          "type": "boolean",
          "description": "Raw runtime-provided bytes were preserved without phase encoding."
        },
        "conversion": {
          "type": "string",
          "description": "Human-readable raw-to-metre rule."
        },
        "views": {
          "type": "array",
          "description": "Native depth payload descriptors in output order.",
          "minItems": 1,
          "maxItems": 2,
          "items": {
            "type": "object",
            "description": "One view-to-PNG-chunk manifest entry.",
            "properties": {
              "viewId": {
                "type": "string",
                "description": "Stable MRPS view ID."
              },
              "eye": {
                "type": "string",
                "description": "XR eye label.",
                "enum": [
                  "none",
                  "left",
                  "right"
                ]
              },
              "xrViewIndex": {
                "type": "integer",
                "description": "Runtime XRView index.",
                "minimum": 0
              },
              "chunkType": {
                "type": "string",
                "description": "Four-character PNG depth chunk type.",
                "minLength": 4,
                "maxLength": 4
              }
            },
            "required": [
              "viewId",
              "eye",
              "xrViewIndex",
              "chunkType"
            ],
            "additionalProperties": true
          }
        }
      },
      "required": [
        "preferredSource",
        "exactDeviceSamplesPreserved",
        "conversion",
        "views"
      ],
      "additionalProperties": true
    },
    "phaseDepthFallback": {
      "type": "object",
      "description": "Four-tile non-authoritative phase-depth fallback parameters.",
      "properties": {
        "purpose": {
          "type": "string",
          "description": "Human-readable warning and purpose."
        },
        "encoding": {
          "type": "string",
          "description": "Encoding identifier."
        },
        "maxDistanceMeters": {
          "type": "number",
          "description": "Phase normalization maximum distance."
        },
        "phaseCycles": {
          "type": "integer",
          "description": "Phase cycles.",
          "minimum": 1
        },
        "zNormDefinition": {
          "type": "string",
          "description": "Human-readable zNorm formula."
        },
        "validUnclippedDecodeMeters": {
          "type": "string",
          "description": "Human-readable inverse formula."
        },
        "nominalPhaseQuantizationStepMeters": {
          "type": "number",
          "description": "Nominal phase step; not an accuracy guarantee."
        },
        "tiles": {
          "type": "object",
          "description": "Formula strings for each phase tile.",
          "properties": {
            "topLeft": {
              "type": "string",
              "description": "Coarse tile formula."
            },
            "topRight": {
              "type": "string",
              "description": "Inverse coarse tile formula."
            },
            "bottomLeft": {
              "type": "string",
              "description": "Sine tile formula."
            },
            "bottomRight": {
              "type": "string",
              "description": "Cosine tile formula."
            }
          },
          "required": [
            "topLeft",
            "topRight",
            "bottomLeft",
            "bottomRight"
          ],
          "additionalProperties": true
        },
        "alphaState": {
          "type": "object",
          "description": "Alpha byte state dictionary. JSON keys are strings.",
          "properties": {
            "0": {
              "type": "string",
              "description": "Meaning of alpha zero."
            },
            "128": {
              "type": "string",
              "description": "Meaning of clipped lower-bound state."
            },
            "255": {
              "type": "string",
              "description": "Meaning of valid within-range state."
            }
          },
          "required": [
            "0",
            "128",
            "255"
          ],
          "additionalProperties": true
        }
      },
      "required": [
        "purpose",
        "encoding",
        "maxDistanceMeters",
        "phaseCycles",
        "zNormDefinition",
        "validUnclippedDecodeMeters",
        "nominalPhaseQuantizationStepMeters",
        "tiles",
        "alphaState"
      ],
      "additionalProperties": true
    },
    "reconstruction": {
      "type": "object",
      "description": "Human-readable reconstruction formulas; normative algorithm is in MRPS_v4_SPEC.md.",
      "properties": {
        "preferredInput": {
          "type": "string",
          "description": "Preferred data source."
        },
        "rawDepthPixelToNormalizedView": {
          "type": "array",
          "description": "Documented depth-pixel-to-view-UV steps.",
          "items": {
            "type": "string"
          }
        },
        "normalizedViewToSensorPoint": {
          "type": "array",
          "description": "Documented sensor ray/unprojection steps.",
          "items": {
            "type": "string"
          }
        },
        "sensorPointToCaptureLocal": {
          "type": "string",
          "description": "Documented sensor-to-capture-local step."
        },
        "attachAtPlaybackViewer": {
          "type": "string",
          "description": "Documented capture-local placement at playback viewer."
        },
        "renderForEachPlaybackView": {
          "type": "array",
          "description": "Documented per-playback-view projection steps.",
          "items": {
            "type": "string"
          }
        },
        "playbackIpdRule": {
          "type": "string",
          "description": "Rule forbidding IPD-based geometry scaling."
        },
        "captureBaselinePurpose": {
          "type": "string",
          "description": "Diagnostic purpose of capture baselines."
        },
        "physicalScale": {
          "type": "string",
          "description": "Metre scale statement."
        }
      },
      "required": [
        "preferredInput",
        "rawDepthPixelToNormalizedView",
        "normalizedViewToSensorPoint",
        "sensorPointToCaptureLocal",
        "attachAtPlaybackViewer",
        "renderForEachPlaybackView",
        "playbackIpdRule",
        "captureBaselinePurpose",
        "physicalScale"
      ],
      "additionalProperties": true
    },
    "occlusion": {
      "type": "object",
      "description": "Metric surface validity and occlusion guidance.",
      "properties": {
        "source": {
          "type": "string",
          "description": "Occlusion source."
        },
        "invalidSamplesCreateHoles": {
          "type": "boolean",
          "description": "Invalid samples produce no geometry."
        },
        "clippedPhaseSamplesAreNotExactOccluders": {
          "type": "boolean",
          "description": "Phase clipped state is only a lower bound."
        },
        "embeddedNativeDepthRecommended": {
          "type": "boolean",
          "description": "Native depth is preferred for exact occlusion."
        },
        "recommendedStartingToleranceMeters": {
          "type": "number",
          "description": "Initial live-depth z comparison tolerance."
        }
      },
      "required": [
        "source",
        "invalidSamplesCreateHoles",
        "clippedPhaseSamplesAreNotExactOccluders",
        "embeddedNativeDepthRecommended",
        "recommendedStartingToleranceMeters"
      ],
      "additionalProperties": true
    },
    "depth": {
      "type": "object",
      "description": "Canonical per-view calibration list plus redundant ID lookup index.",
      "properties": {
        "views": {
          "type": "array",
          "description": "Canonical ordered depth-view calibration records.",
          "minItems": 1,
          "maxItems": 2,
          "items": {
            "$ref": "#/$defs/depthView"
          }
        },
        "byId": {
          "type": "object",
          "description": "Redundant convenience index keyed by viewId; depth.views is canonical.",
          "additionalProperties": {
            "$ref": "#/$defs/depthView"
          }
        }
      },
      "required": [
        "views",
        "byId"
      ],
      "additionalProperties": true
    },
    "atlasStatistics": {
      "type": "object",
      "description": "Logical phase-grid validity counts keyed by active view ID.",
      "properties": {
        "mono": {
          "$ref": "#/$defs/stats"
        },
        "left": {
          "$ref": "#/$defs/stats"
        },
        "right": {
          "$ref": "#/$defs/stats"
        }
      },
      "minProperties": 1,
      "additionalProperties": true
    }
  },
  "required": [
    "schema",
    "captureId",
    "capturedAt",
    "files",
    "assumptions",
    "coordinateSystem",
    "source",
    "captureTrigger",
    "viewConfiguration",
    "timing",
    "output",
    "rgb",
    "depthSession",
    "metricDepth",
    "phaseDepthFallback",
    "reconstruction",
    "occlusion",
    "depth",
    "atlasStatistics"
  ],
  "additionalProperties": true,
  "$defs": {
    "matrix": {
      "type": "array",
      "description": "Column-major 4x4 matrix using column vectors.",
      "minItems": 16,
      "maxItems": 16,
      "items": {
        "type": "number"
      }
    },
    "vec3": {
      "type": "array",
      "description": "Three-component vector expressed in capture-local metres.",
      "minItems": 3,
      "maxItems": 3,
      "items": {
        "type": "number"
      }
    },
    "rect": {
      "type": "object",
      "description": "Top-left-origin pixel or normalized rectangle.",
      "properties": {
        "x": {
          "type": "number",
          "description": "Left coordinate."
        },
        "y": {
          "type": "number",
          "description": "Top coordinate."
        },
        "width": {
          "type": "number",
          "description": "Rectangle width."
        },
        "height": {
          "type": "number",
          "description": "Rectangle height."
        }
      },
      "required": [
        "x",
        "y",
        "width",
        "height"
      ],
      "additionalProperties": true
    },
    "sourceRect": {
      "type": "object",
      "description": "Top-left-origin rectangle selecting a logical mono or SBS source view.",
      "properties": {
        "x": {
          "type": "number",
          "description": "Left coordinate."
        },
        "y": {
          "type": "number",
          "description": "Top coordinate."
        },
        "width": {
          "type": "number",
          "description": "Rectangle width."
        },
        "height": {
          "type": "number",
          "description": "Rectangle height."
        },
        "layout": {
          "type": "string",
          "description": "Logical source layout.",
          "enum": [
            "mono",
            "sbs"
          ]
        }
      },
      "required": [
        "x",
        "y",
        "width",
        "height",
        "layout"
      ],
      "additionalProperties": true
    },
    "resolution": {
      "type": "object",
      "description": "Stored image resolution in pixels.",
      "properties": {
        "width": {
          "type": "integer",
          "description": "Pixel width.",
          "minimum": 1
        },
        "height": {
          "type": "integer",
          "description": "Pixel height.",
          "minimum": 1
        }
      },
      "required": [
        "width",
        "height"
      ],
      "additionalProperties": true
    },
    "mapping": {
      "type": "object",
      "description": "Exact source crop, aspect-fit, and stored-slot mapping.",
      "properties": {
        "fitMode": {
          "type": "string",
          "description": "Aspect policy.",
          "enum": [
            "contain",
            "cover"
          ]
        },
        "sourceRectPixels": {
          "$ref": "#/$defs/sourceRect"
        },
        "sampledSourceRectPixels": {
          "$ref": "#/$defs/sourceRect"
        },
        "normalizedViewRect": {
          "$ref": "#/$defs/rect"
        },
        "storedActiveRectPixels": {
          "$ref": "#/$defs/rect"
        },
        "storedActiveRectNormalized": {
          "$ref": "#/$defs/rect"
        },
        "storedResolution": {
          "$ref": "#/$defs/resolution"
        }
      },
      "required": [
        "fitMode",
        "sourceRectPixels",
        "sampledSourceRectPixels",
        "normalizedViewRect",
        "storedActiveRectPixels",
        "storedActiveRectNormalized",
        "storedResolution"
      ],
      "additionalProperties": true
    },
    "payload": {
      "type": "object",
      "description": "Descriptor for one embedded MRD1 native-depth PNG chunk.",
      "properties": {
        "chunkType": {
          "type": "string",
          "description": "Four-character private PNG chunk type containing this depth payload.",
          "minLength": 4,
          "maxLength": 4
        },
        "payloadMagic": {
          "type": "string",
          "description": "Binary payload magic; MRD1.",
          "const": "MRD1"
        },
        "headerVersion": {
          "type": "integer",
          "description": "MRD1 header version.",
          "const": 1
        },
        "headerBytes": {
          "type": "integer",
          "description": "MRD1 header byte count.",
          "const": 28
        },
        "rawElementType": {
          "type": "string",
          "description": "Serialized sample type.",
          "enum": [
            "uint16",
            "float32"
          ]
        },
        "rawByteOrder": {
          "type": "string",
          "description": "Byte order of raw sample bytes.",
          "enum": [
            "little-endian",
            "big-endian"
          ]
        },
        "rawByteLength": {
          "type": "integer",
          "description": "Length of raw sample bytes.",
          "minimum": 0
        },
        "payloadByteLength": {
          "type": "integer",
          "description": "Total MRD1 payload length including 28-byte header.",
          "minimum": 28
        },
        "sha256OfRawBytes": {
          "anyOf": [
            {
              "type": "string",
              "description": "Lowercase hexadecimal SHA-256 of raw bytes.",
              "pattern": "^[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ],
          "description": "Optional raw-byte SHA-256; null when unavailable."
        },
        "headerLayoutLittleEndian": {
          "type": "object",
          "description": "Human-readable MRD1 header offset dictionary; values are documentation strings.",
          "properties": {
            "magic": {
              "type": "string",
              "description": "Meaning/offset of MRD1 magic."
            },
            "version": {
              "type": "string",
              "description": "Meaning/offset of version byte."
            },
            "formatCode": {
              "type": "string",
              "description": "Meaning/offset of sample-format code."
            },
            "rawByteOrderCode": {
              "type": "string",
              "description": "Meaning/offset of raw-byte-order code."
            },
            "width": {
              "type": "string",
              "description": "Meaning/offset of width."
            },
            "height": {
              "type": "string",
              "description": "Meaning/offset of height."
            },
            "rawValueToMeters": {
              "type": "string",
              "description": "Meaning/offset of metric scale."
            },
            "rawByteLength": {
              "type": "string",
              "description": "Meaning/offset of raw length."
            },
            "rawBytes": {
              "type": "string",
              "description": "Offset at which raw samples begin."
            }
          },
          "required": [
            "magic",
            "version",
            "formatCode",
            "rawByteOrderCode",
            "width",
            "height",
            "rawValueToMeters",
            "rawByteLength",
            "rawBytes"
          ],
          "additionalProperties": true
        }
      },
      "required": [
        "chunkType",
        "payloadMagic",
        "headerVersion",
        "headerBytes",
        "rawElementType",
        "rawByteOrder",
        "rawByteLength",
        "payloadByteLength",
        "sha256OfRawBytes",
        "headerLayoutLittleEndian"
      ],
      "additionalProperties": true
    },
    "nativeBuffer": {
      "type": "object",
      "description": "Native WebXR CPU depth-buffer description and payload location.",
      "properties": {
        "width": {
          "type": "integer",
          "description": "Native depth columns.",
          "minimum": 1
        },
        "height": {
          "type": "integer",
          "description": "Native depth rows.",
          "minimum": 1
        },
        "dataFormat": {
          "type": "string",
          "description": "Granted WebXR depth data format."
        },
        "elementType": {
          "type": "string",
          "description": "In-memory and serialized sample type.",
          "enum": [
            "uint16",
            "float32"
          ]
        },
        "rawValueToMeters": {
          "type": "number",
          "description": "Device scale converting raw samples to camera-plane Z metres."
        },
        "invalidRawValue": {
          "type": "number",
          "description": "Raw value representing invalid/no depth; zero."
        },
        "rowOrder": {
          "type": "string",
          "description": "Row traversal order.",
          "const": "top-to-bottom"
        },
        "storageOrder": {
          "type": "string",
          "description": "Sample storage order.",
          "const": "row-major"
        },
        "payload": {
          "$ref": "#/$defs/payload"
        }
      },
      "required": [
        "width",
        "height",
        "dataFormat",
        "elementType",
        "rawValueToMeters",
        "invalidRawValue",
        "rowOrder",
        "storageOrder",
        "payload"
      ],
      "additionalProperties": true
    },
    "viewport": {
      "type": "object",
      "description": "XRWebGLLayer framebuffer viewport in pixels.",
      "properties": {
        "x": {
          "type": "integer",
          "description": "Viewport x."
        },
        "y": {
          "type": "integer",
          "description": "Viewport y."
        },
        "width": {
          "type": "integer",
          "description": "Viewport width.",
          "minimum": 0
        },
        "height": {
          "type": "integer",
          "description": "Viewport height.",
          "minimum": 0
        }
      },
      "required": [
        "x",
        "y",
        "width",
        "height"
      ],
      "additionalProperties": true
    },
    "depthView": {
      "type": "object",
      "description": "Full calibration and native-buffer descriptor for one capture view.",
      "properties": {
        "viewId": {
          "type": "string",
          "description": "Stable MRPS view identifier."
        },
        "eye": {
          "type": "string",
          "description": "XR eye label.",
          "enum": [
            "none",
            "left",
            "right"
          ]
        },
        "viewArrayIndex": {
          "type": "integer",
          "description": "Index in capture XRViewerPose.views.",
          "minimum": 0
        },
        "xrViewIndex": {
          "type": "integer",
          "description": "XRView.index when exposed, otherwise array index.",
          "minimum": 0
        },
        "nativeBuffer": {
          "$ref": "#/$defs/nativeBuffer"
        },
        "normalizedCoordinates": {
          "type": "object",
          "description": "Normalized view/depth coordinate conventions and transforms.",
          "properties": {
            "origin": {
              "type": "string",
              "description": "Normalized coordinate origin.",
              "const": "top-left"
            },
            "xDirection": {
              "type": "string",
              "description": "Positive normalized X direction.",
              "const": "right"
            },
            "yDirection": {
              "type": "string",
              "description": "Positive normalized Y direction.",
              "const": "down"
            },
            "normDepthBufferFromNormView": {
              "type": "array",
              "description": "Maps normalized view coordinates into normalized depth-buffer coordinates.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "normViewFromNormDepthBuffer": {
              "type": "array",
              "description": "Inverse mapping used to unproject native depth pixels.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            }
          },
          "required": [
            "origin",
            "xDirection",
            "yDirection",
            "normDepthBufferFromNormView",
            "normViewFromNormDepthBuffer"
          ],
          "additionalProperties": true
        },
        "xrViewGeometry": {
          "type": "object",
          "description": "Capture-time associated XR render-view projection and transform.",
          "properties": {
            "projectionMatrix": {
              "type": "array",
              "description": "Capture XRView projection matrix.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "projectionMatrixInverse": {
              "anyOf": [
                {
                  "type": "array",
                  "description": "Column-major 4x4 matrix using column vectors.",
                  "minItems": 16,
                  "maxItems": 16,
                  "items": {
                    "type": "number"
                  }
                },
                {
                  "type": "null"
                }
              ],
              "description": "Inverse capture XRView projection, or null if unavailable."
            },
            "captureLocalFromView": {
              "type": "array",
              "description": "Maps capture XR-view coordinates into capture-local coordinates.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "viewFromCaptureLocal": {
              "type": "array",
              "description": "Inverse of captureLocalFromView.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "viewport": {
              "anyOf": [
                {
                  "$ref": "#/$defs/viewport"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Capture framebuffer viewport; diagnostic, not camera intrinsics."
            }
          },
          "required": [
            "projectionMatrix",
            "projectionMatrixInverse",
            "captureLocalFromView",
            "viewFromCaptureLocal",
            "viewport"
          ],
          "additionalProperties": true
        },
        "sensorGeometry": {
          "type": "object",
          "description": "Authoritative depth-sensor projection and pose for metric unprojection.",
          "properties": {
            "projectionMatrix": {
              "type": "array",
              "description": "Depth-sensor projection matrix.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "projectionMatrixInverse": {
              "type": "array",
              "description": "Inverse depth-sensor projection used to build rays.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "captureLocalFromSensor": {
              "type": "array",
              "description": "Maps depth-sensor coordinates into capture-local metres.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "sensorFromCaptureLocal": {
              "type": "array",
              "description": "Inverse of captureLocalFromSensor.",
              "minItems": 16,
              "maxItems": 16,
              "items": {
                "type": "number"
              }
            },
            "projectionSource": {
              "type": "string",
              "description": "API source or explicit XRView fallback for the sensor projection."
            },
            "transformSource": {
              "type": "string",
              "description": "API source or explicit XRView fallback for the sensor pose."
            },
            "depthMeaning": {
              "type": "string",
              "description": "Depth semantic; camera-plane Z from sensor plane."
            }
          },
          "required": [
            "projectionMatrix",
            "projectionMatrixInverse",
            "captureLocalFromSensor",
            "sensorFromCaptureLocal",
            "projectionSource",
            "transformSource",
            "depthMeaning"
          ],
          "additionalProperties": true
        },
        "rgbAndAtlasMapping": {
          "$ref": "#/$defs/mapping"
        }
      },
      "required": [
        "viewId",
        "eye",
        "viewArrayIndex",
        "xrViewIndex",
        "nativeBuffer",
        "normalizedCoordinates",
        "xrViewGeometry",
        "sensorGeometry",
        "rgbAndAtlasMapping"
      ],
      "additionalProperties": true
    },
    "captureTrigger": {
      "type": "object",
      "description": "Diagnostic description of the action that requested capture.",
      "properties": {
        "type": {
          "type": "string",
          "description": "Trigger family or implementation/test label."
        },
        "eventType": {
          "anyOf": [
            {
              "type": "string",
              "description": "DOM or WebXR event name."
            },
            {
              "type": "null"
            }
          ],
          "description": "DOM or WebXR event name. May be null when unavailable."
        },
        "targetRayMode": {
          "anyOf": [
            {
              "type": "string",
              "description": "WebXR target-ray mode."
            },
            {
              "type": "null"
            }
          ],
          "description": "WebXR target-ray mode. May be null when unavailable."
        },
        "handedness": {
          "type": "string",
          "description": "WebXR input handedness."
        },
        "profiles": {
          "type": "array",
          "description": "WebXR input profile names.",
          "items": {
            "type": "string"
          }
        },
        "pointerType": {
          "anyOf": [
            {
              "type": "string",
              "description": "DOM pointer type."
            },
            {
              "type": "null"
            }
          ],
          "description": "DOM pointer type. May be null when unavailable."
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": true
    },
    "baseline": {
      "type": "object",
      "description": "Stereo capture baseline/IPD-equivalent diagnostics; complete matrices remain authoritative.",
      "properties": {
        "viewLeftToRightMeters": {
          "type": "array",
          "description": "Right XR-view origin minus left origin in capture-local axes.",
          "minItems": 3,
          "maxItems": 3,
          "items": {
            "type": "number"
          }
        },
        "viewOriginDistanceMeters": {
          "type": "number",
          "description": "Magnitude of the XR-view baseline vector."
        },
        "depthSensorLeftToRightMeters": {
          "type": "array",
          "description": "Right depth-sensor origin minus left sensor origin.",
          "minItems": 3,
          "maxItems": 3,
          "items": {
            "type": "number"
          }
        },
        "depthSensorOriginDistanceMeters": {
          "type": "number",
          "description": "Magnitude of the depth-sensor baseline vector."
        },
        "ipdEquivalentMeters": {
          "type": "number",
          "description": "Convenience duplicate of viewOriginDistanceMeters; not guaranteed biological IPD."
        },
        "ipdEquivalentSource": {
          "type": "string",
          "description": "Derivation of the IPD-equivalent value."
        },
        "depthCameraBaselineMeters": {
          "type": "number",
          "description": "Convenience duplicate of depthSensorOriginDistanceMeters."
        },
        "isGuaranteedBiologicalInterpupillaryDistance": {
          "type": "boolean",
          "description": "False; exposed view separation is not guaranteed biological IPD."
        },
        "isGuaranteedPhysicalRgbCameraSeparation": {
          "type": "boolean",
          "description": "False; RGB lens separation is not exposed by getUserMedia."
        },
        "mayBeAnonymizedOrQuantizedByUserAgent": {
          "type": "boolean",
          "description": "Signals possible privacy adjustment of XR view relationship."
        },
        "useAsPlaybackEyeSeparation": {
          "type": "boolean",
          "description": "False; playback uses current runtime XRView transforms."
        }
      },
      "required": [
        "viewLeftToRightMeters",
        "viewOriginDistanceMeters",
        "depthSensorLeftToRightMeters",
        "depthSensorOriginDistanceMeters",
        "ipdEquivalentMeters",
        "ipdEquivalentSource",
        "depthCameraBaselineMeters",
        "isGuaranteedBiologicalInterpupillaryDistance",
        "isGuaranteedPhysicalRgbCameraSeparation",
        "mayBeAnonymizedOrQuantizedByUserAgent",
        "useAsPlaybackEyeSeparation"
      ],
      "additionalProperties": true
    },
    "quadrant": {
      "type": "object",
      "description": "One top-left-origin rectangle in the visible 2048-square atlas.",
      "properties": {
        "role": {
          "type": "string",
          "description": "Semantic role such as mono-rgb, left-depth-atlas, or unused."
        },
        "viewId": {
          "type": "string",
          "description": "Associated MRPS view ID when active."
        },
        "x": {
          "type": "integer",
          "description": "Left pixel coordinate."
        },
        "y": {
          "type": "integer",
          "description": "Top pixel coordinate."
        },
        "width": {
          "type": "integer",
          "description": "Rectangle width.",
          "minimum": 1
        },
        "height": {
          "type": "integer",
          "description": "Rectangle height.",
          "minimum": 1
        }
      },
      "required": [
        "role",
        "x",
        "y",
        "width",
        "height"
      ],
      "additionalProperties": true
    },
    "stats": {
      "type": "object",
      "description": "Counts over one logical phase-atlas grid, before four-tile repetition.",
      "properties": {
        "valid": {
          "type": "integer",
          "description": "Valid samples within phase range.",
          "minimum": 0
        },
        "clipped": {
          "type": "integer",
          "description": "Valid native samples beyond phase max distance.",
          "minimum": 0
        },
        "invalid": {
          "type": "integer",
          "description": "Invalid samples or samples outside active mapping.",
          "minimum": 0
        },
        "total": {
          "type": "integer",
          "description": "Total logical samples.",
          "minimum": 0
        }
      },
      "required": [
        "valid",
        "clipped",
        "invalid",
        "total"
      ],
      "additionalProperties": true
    }
  }
}