diff --git a/branding/ui-icons/icons.py b/branding/ui-icons/icons.py index d135e731..196a2bef 100644 --- a/branding/ui-icons/icons.py +++ b/branding/ui-icons/icons.py @@ -138,6 +138,28 @@ I["Triangle"] = (None, "M8 3 L13.5 12.5 H2.5 Z") I["TriangleRight"] = (None, "M5 3 L12 8 L5 13 Z") I["Cross"] = ("M4.5 4.5 L11.5 11.5 M11.5 4.5 L4.5 11.5", None) +# Owner review 1, R6: the Camera step's orientation controls. A turn is a picture under a quarter-circle arrow; mirror and +# flip are two triangles across a dashed axis, the outline one becoming the filled one; straighten levels a tilted line. +def head(tx, ty, angle, size=2.4, spread=40): + """Arrowhead strokes ending at (tx, ty) for travel along angle degrees (0 = 12 o'clock, clockwise).""" + f = lambda v: f"{v:.2f}".rstrip("0").rstrip(".") + back = math.radians(angle + 180) + wing = lambda d: (tx + size * math.sin(back + math.radians(d)), ty - size * math.cos(back + math.radians(d))) + (ax, ay), (bx, by) = wing(-spread), wing(spread) + return f"M{f(ax)} {f(ay)} L{f(tx)} {f(ty)} L{f(bx)} {f(by)}" + +def turn_arrow(clockwise): + cx, cy, r, a0, a1 = 8, 8.5, 5.5, 295, 65 + x1, y1 = cx + r * math.sin(math.radians(a1)), cy - r * math.cos(math.radians(a1)) + x0, y0 = cx + r * math.sin(math.radians(a0)), cy - r * math.cos(math.radians(a0)) + return arc(cx, cy, r, a0, a1) + " " + (head(x1, y1, a1 + 90) if clockwise else head(x0, y0, a0 - 90)) + +I["RotateRight"] = (rr(4.5,9.5,7,5,1)+" "+turn_arrow(True), None) +I["RotateLeft"] = (rr(4.5,9.5,7,5,1)+" "+turn_arrow(False), None) +I["Mirror"] = ("M8 1.5 V3 M8 5.5 V7.5 M8 10 V12 M8 14 V14.5 M6 4 V12.5 H1.5 Z", "M10 4 L14.5 12.5 H10 Z") +I["Flip"] = ("M1.5 8 H3 M5.5 8 H7.5 M10 8 H12 M14 8 H14.5 M4 6 H12.5 V1.5 Z", "M4 10 L12.5 14.5 V10 Z") +I["Straighten"] = ("M1.5 12.5 H14.5 M2.5 12.5 L13 6 "+arc(2.5,12.5,7,58.2,90), None) + # Glyphs that point along the reading direction (arrows, chevrons, start-aligned text lines): mirrored in RTL. # Everything else (clocks, media controls, the ▶ rendered status, symmetric shapes) never mirrors. DIRECTIONAL = {"Back", "Forward", "ChevronLeft", "ChevronRight", "ExternalLink", "Jobs", "Logs", "ViewList"} diff --git a/branding/ui-icons/icons.svg b/branding/ui-icons/icons.svg index 1357fcf5..b13c3b03 100644 --- a/branding/ui-icons/icons.svg +++ b/branding/ui-icons/icons.svg @@ -149,269 +149,291 @@ Filter + + + +Flip + -Folder - +Folder + -FolderOpen - +FolderOpen + -Forward - +Forward + -Fullscreen - +Fullscreen + -Gpu - +Gpu + -Grip - +Grip + -HalfDot - +HalfDot + -Hero - +Hero + -Image - +Image + -Import - +Import + -Info - +Info + -Jobs - +Jobs + -Key - +Key + -Keyframe - +Keyframe + -Layers - +Layers + -Library - +Library + -Link - +Link + -Lock - +Lock + -Logs - +Logs + -Menu - +Menu + -Minus - +Minus + + + + +Mirror + -Moon - +Moon + -More - +More + -Motion - +Motion + -Network - +Network + -Optimise - +Optimise + -Pause - +Pause + -Play - +Play + -Plus - +Plus + -Power - +Power + -Refresh - +Refresh + -Regions - +Regions + -Render - +Render + -Reset - +Reset + -Retry - +Retry + -Ring - +Ring + + + +RotateLeft + + + +RotateRight + -Search - +Search + -Sequence - +Sequence + -Server - +Server + -Settings - +Settings + -Sort - +Sort + -Spline - +Spline + -Stack - +Stack + -Star - +Star + -StarFilled - +StarFilled + -Stop - +Stop + + + +Straighten + -SuccessCircle - +SuccessCircle + -Sun - +Sun + -Sync - +Sync + -Tag - +Tag + -Time - +Time + -Tray - +Tray + -Triangle - +Triangle + -TriangleRight - +TriangleRight + -Upload - +Upload + -User - +User + -Users - +Users + -Vectors - +Vectors + -Verify - +Verify + -ViewGrid - +ViewGrid + -ViewList - +ViewList + -ViewTimeline - +ViewTimeline + -Warning - +Warning + -Window - +Window + -Wipe +Wipe \ No newline at end of file diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 35ac6fa5..be3ecca2 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -701,3 +701,21 @@ One line per decision: date · decision · alternative · reason. | 2026-11-04 | A move's failure and cancel: before the switch, renamed entries go back (if that fails the journal stays and the workspace stays held until Resume) and copies at the target are removed, the journal deleted; a user cancel (running, paused or failed) undoes it the same way. After the switch nothing is undone: a source entry goes only while each file still matches its verified copy (name, size, time), one changed since is kept and logged, one held open keeps the journal, and the job ends Done with `Archive.Log.WorkspaceMoveLeft`; the next run clears the rest. A pause, a yield or closing the program keep the journal. A resumed move does not check for other jobs again. (Owner review 2, R8, phase 5c; review safety-3, tests-3.) | Fail the job after the switch | The target is the workspace by then; refusing to resume would strand a half-done move. | | 2026-11-04 | Jobs and the move: `WorkspaceJobRoots.Resolve` (Data) makes a copy, render or send work in the folder that holds its project now (the one named, a switched move's target, or the folder in use through `CurrentRoot`), and refuses it (`Errors.Workspace.Moving`) while a move of either folder has not switched; a retry after the move then works. The desktop's gate (`WorkspaceHost.IsMoving`: a move job queued, running or paused, followed through `JobChanged` and adopted at start, or a journal in the folder in use) holds checkout, copies, Proxies only, save, sync, conflicts, restore, the picker's lists, rename, delete, Remove local copy, Change, Empty… and the clean-up. A journal at start, also one left in the old folder of a switched move into the folder in use, raises a notice and Settings shows *Resume*; Change… and Move… stay disabled meanwhile, their tooltips saying why. (Owner review 2, R8, phase 5c; review jobs-6, integration-2, integration-3, integration-6, ui-3; final check.) | Gate only the desktop's commands | Engine retries bypassed the gate and wrote into the old folder; choosing another folder before Resume would lose the old copy for good. | | 2026-11-04 | Phase 5c strings: every new key in en and it with final text; 19 unused keys removed from en and it and `i18n prune` removed 144 orphans from the other cultures; `Errors.Workspace.DiskFull` kept (the copy's space check). The Italian move plan, trash and job kind wordings were revised. (Owner review 2, R8, phase 5c; review ui-8, ui-9.) | Keep unused keys for later | Unused keys cost every translation. | +| 2026-11-04 | Conditional settings format: `ProjectSettings.CurrentVersion = 2` is the highest format this build reads; `ToJson` writes the lowest format that renders the same (`RequiredFormat`: 2 only when a turn, mirror, flip, straighten or non-identity look is set, otherwise `BaseVersion` 1; a newer project read-only keeps its own number through `WrittenFormat`); `ProjectContent.FormatOf` falls back to 1. (Owner review 1, R5/R6, phase 4.) | Always write 2 | Every project that does not use the new features keeps byte-identical canonical text and hash, so no External versions appear and older builds treat it as before. | +| 2026-11-04 | Rule for future settings members: a member that changes pixels and that the previous format would ignore raises the written format only when it is used; it is declared after the existing members, before `Extra`, and omitted at its default; lists that grow are strings, not enums. (Owner review 1, phase 4.) | Bump the format per release | Keeps old text stable and lets an older build carry the member through `Extra` in the same place. | +| 2026-11-04 | Orientation members and order: `camera.rotate` 0/90/180/270 clockwise after Exif orientation, then `mirror` (left↔right) and `flip` (top↔bottom) in screen axes after the turn, then `straighten` ±15° positive clockwise; all inside the single warp between stabilisation and the virtual camera. Pixels are never rotated after decode. (Owner review 1, R5, phase 4.) | Rotate the decoded pixels | Stabiliser paths, the sky mask and the horizon stay in raw-frame space and one resample is kept. | +| 2026-11-04 | Straighten cover zoom is automatic and never stored: c = cos\|θ\| + max(W'/H', H'/W')·sin\|θ\| (`FrameOrientation.CoverZoomOf`). (Owner review 1, R5, phase 4.) | A user zoom or a clamped border | No smeared border can ever show and any crop in [0,1]² stays valid. | +| 2026-11-04 | Crop coordinates: `camera.crop` and the keyframe centres are normalised in the view frame T (oriented, straightened, cover-zoomed), which is today's meaning for the identity transform; the crop stays one atomic array in `ProjectMerge`, so a concurrent move and resize give one `camera.crop` conflict. (Owner review 1, R5, phase 4.) | Raw-frame coordinates; per-edge merge | The mask maps 1:1 to the stored crop and a merge never yields a rectangle of the wrong ratio. | +| 2026-11-04 | Locked crop: editor edits write the aspect-locked box itself with `offsetX`/`offsetY` 0, so `FitCrop` returns it unchanged; the first edit of a legacy free crop with offsets bakes them in (`FitCrop(crop, ratio, offsets)`); the renderer keeps `FitCrop` as the safety net; an aspect change refits the box (same centre, new ratio, inside the frame). (Owner review 1, R5, phase 4.) | Keep free crops plus offsets | What the user drags is what renders. | +| 2026-11-04 | A quarter turn keeps the content: rotate left/right remaps the crop and keyframe centres exactly and transposes a non-square aspect (manual or the Auto's advised value: 16:9 → 9:16); mirror and flip remap crop and centres and negate the keyframe roll; each press is one undo step (`OrientationEdit`). (Owner review 1, R5, phase 4.) | Reset the framing on a turn | The framed subject stays framed. | +| 2026-11-04 | Proportions win: when the resolved aspect is not "source", a fixed-size preset is a size box and the aspect is fitted inside it, the box turned to portrait for a ratio below 1 (4K at 9:16 = 2160×3840, 1:1 = 2160×2160, 4:5 = 2160×2700, 21:9 = 3840×1646; 1080p at 9:16 = 1080×1920); "source" keeps the preset's size; sizes stay even for non-managed codecs; `AspectFromPreset` is removed and the preset name does not flip to Custom (`RenderSize`). (Owner review 1, R6, phase 4.) | The preset ratio wins (crop in the preset frame) | The chosen proportions are what the user asked for; default projects do not change. | +| 2026-11-04 | Proportions win is not format-gated in storage: raising the format for it would drift the canonical text of stored projects and spawn External versions; it is gated only in routing and in the desktop's server gating, and the output change is a CHANGELOG upgrade note. (Owner review 1, R6, phase 4.) | Write format 2 for it | Stored projects keep their hash. | +| 2026-11-04 | Routing format: `RenderRules.RequiredFormat(settings, export, srcW, srcH)` = max(written format, 2 when the adapted size differs from the preset's fixed size), never written; nodes announce `RegisterNodeRequest.SettingsFormat` (older node = 1); jobs carry `RenderJobParameters.RequiredSettingsFormat`; a claim and the "awaits a node" check skip incompatible nodes. (Owner review 1, phase 4.) | Send every job to every node | An older node never renders a job it would get wrong. | +| 2026-11-04 | Server format announcement: `ServerInfo.SettingsFormat` is new (null from an older server = 1); the desktop disables Push and Send-and-render when the required format exceeds the server's, with a tooltip giving the reason (`Tooltips.Server.NeedsNewerServer`). (Owner review 1, phase 4.) | Let the server refuse | The user sees why before acting. | +| 2026-11-04 | Colour look: parametric and built in (no LUT files a server or Docker image would lack): a linear-light 3×3 matrix, a contrast power about 0.18 and a lift, blended by strength; applied once per output frame after stacking, interpolation and blur and before the knee (`FrameFinish`), never seen by measuring, flow or stacking; `look.filter` is a string and an unknown name renders as identity with `Export.Render.LookIgnored`. (Owner review 1, R6, phase 4.) | LUT files; look before stacking | Same pixels everywhere, the knee compresses any overshoot, analysis stays on real data. | +| 2026-11-04 | No ninth step: the transforms join the Camera step and the look joins the Exposure step (BRIEF §12.3); Alt+1…8, "n / 8" and the 82-px step cells are unchanged. (Owner review 1, phase 4.) | A Transform or Look step | Keeps the eight-step model. | +| 2026-11-04 | Raw thumbnails: library, filmstrip, hero and admin-panel covers stay raw photos, without transforms or look. (Owner review 1, phase 4.) | Oriented covers | Thumbnails are frame identity, not output previews, and need no render. | +| 2026-11-04 | Preview Source framing: with a non-identity transform the whole T frame is shown without stabilisation or camera pose, so the Camera-step mask is static and maps 1:1 to `camera.crop`; the Export step shows the per-frame output footprint mapped into T (`RenderGeometry.FootprintInView`). (Owner review 1, R5, phase 4.) | Show the raw frame | The mask the user drags is the stored crop. | +| 2026-11-04 | Global only: the new settings are not per-frame and not frame-keyed, so there are no new parked positions; the keyframe `Rotation` roll is unchanged. (Owner review 1, phase 4.) | Keyframed straighten or look | Simple, and roll already covers per-frame tilt. | +| 2026-11-04 | Phase 4 compatibility: new server + old node: v1 rendered by the node, v2 and proportions-win jobs never sent to it; old server + new desktop: v1 works, v2 push and render disabled with a reason, proportions-win render disabled (push works); new server + old desktop: v1 works, v2 listed and opened read-only, never mirrored or merged, the old desktop's own render uses the preset ratio (known limitation); old desktop local: v2 read-only, a format-1 `.chronos` refuses it, proportions-win renders at the preset ratio (CHANGELOG note). (Owner review 1, phase 4.) | — | Records the matrix the format, routing and gating rows give. | +| 2026-11-04 | Phase 4 groundwork details: `ProjectSettings.WrittenFormat` (the format `ToJson` stamps, a newer project's own number); `EditPath.HasHandValues` counts a crop only when not whole (`CropFrame.IsWhole`), which matches today; FrameFinish clamps the look strength to 0..1 (missing = 1) and an unknown look still writes format 2 (it is a newer Chronos's); look names are ordinal and case-sensitive; `OrientationEdit` also remaps offsets and pending keyframes, negates straighten on mirror/flip, normalises rotate to 0..270 and rounds remapped coordinates to 12 decimals so four turns give the original text; the SelfTest geometry and colour checks sit before the robustness checks. (Owner review 1, phase 4.) | — | Simplest safe choices where the plan was silent. | diff --git a/i18n/en/Editor.resx b/i18n/en/Editor.resx index 5124eeb4..5103bd9b 100644 --- a/i18n/en/Editor.resx +++ b/i18n/en/Editor.resx @@ -29,14 +29,24 @@ Crop bottom Crop left Crop right + Crop size Crop top + Crop X + Crop Y Keyframes + Flip Keyframe {0} of {1} · {2} {0} keyframe {0} keyframes + Mirror Horizontal placement Vertical placement Remove keyframe + Reset framing + Rotate left + Rotate right + Rotation + Straighten Zoom Change sequence cloud cover % @@ -79,6 +89,7 @@ Batch… {0} bppinvariant Choose folder… + {0} (capped){0} output size as width×height Codec Colour Container @@ -97,6 +108,7 @@ {0} Mb/sinvariant No renders yet Output · {0} + Output size Export preset Quality Quality {0} @@ -180,6 +192,17 @@ History of {0}{0} project name Version {0}{0} version number Opening sequence + Cool + Fade + Filter + Look + Mono + Muted + None + Sepia + Strength + Vivid + Warm Cut: pause or gap Keyframe Exposure step {0} EV @@ -227,6 +250,7 @@ Compare Crop mask Crop result + x {0}, y {1}, size {2}automation value of the crop box; {0} left edge, {1} top edge, {2} size, each a percentage Exit full screen Full screen output {0} diff --git a/i18n/en/Errors.resx b/i18n/en/Errors.resx index e29c29ca..bf9cac67 100644 --- a/i18n/en/Errors.resx +++ b/i18n/en/Errors.resx @@ -19,6 +19,7 @@ The project's settings are larger than {0} MB; Chronos cannot store them.{0} megabytes {0} could not be downloaded intact.{0} file name Exports failed: {0} of {1}; see the job log.{0} failed count; {1} total count + These settings need a newer Chronos. Render nodes send back one file per job; post each preset of a batch as its own job.long Render nodes send back one file per job; image sequences render where the archive is. The render job has no valid export settings. diff --git a/i18n/en/Export.resx b/i18n/en/Export.resx index 28116072..d6561baa 100644 --- a/i18n/en/Export.resx +++ b/i18n/en/Export.resx @@ -70,11 +70,14 @@ Frame {0} ({1}) cannot be decoded; exclude it or check the file.long; {0} frame number from 1; {1} file name The keyframe at frame {0} is invalid and was skipped.long; {0} source frame number Highlight knee {0} is out of range and is ignored.long; {0} knee value as entered + Look “{0}” not known; the colours are left as they are.long; {0} filter name as stored Every frame is excluded; there is nothing to render.long No sky and land mask; deflicker uses the whole frame.long The sky and land mask is uncertain (confidence {0}); deflicker uses the whole frame.long; {0} mask confidence between 0 and 1 + Rotation {0}° is not a quarter turn and is ignored.long; {0} rotation in degrees as stored Strong shake: stabilisation would keep only {0} of the frame, so borders may show.long; {0} kept fraction of the frame between 0 and 1 Stabilisation is unavailable: too little detail to track.long + Straighten {0}° is out of range; {1}° is used.long; {0} angle in degrees as stored; {1} angle in degrees used The container does not suit the codec; the codec's container is used.long Unknown codec; the preset's codec is used.long Unknown frame rate; the preset's frame rate is used.long diff --git a/i18n/en/Server.resx b/i18n/en/Server.resx index 4746df7d..92a83945 100644 --- a/i18n/en/Server.resx +++ b/i18n/en/Server.resx @@ -164,13 +164,18 @@ Export values Exposure offset Fit to duration + Flip Flow quality Frame rate Hero frame Highlight knee Holy grail Camera keyframes + Look + Look filter + Look strength manual + Mirror Motion blur Notes off @@ -179,10 +184,12 @@ Output name Rating Regions + Rotation Shutter angle Stabilisation Stabilisation smoothing Stacking + Straighten Tags Time remap Timing mode diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index a5521791..0e87c3ae 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -136,17 +136,28 @@ Back to Library An analysis or render of this sequence is running; settings wait until it ends Add a keyframe at the current frame - Output aspect ratio; a preset with a fixed size uses its own + Output proportions; a preset's resolution adapts to them (4K at 9:16 = 2160×3840) Horizontal centre of the selected keyframe’s view Vertical centre of the selected keyframe’s view Cuts this share of the frame on that side; aspect and placement then apply inside the crop + Size of the crop as a share of the largest one the aspect allows; drag a handle on the preview too + Moves the crop left or right within the frame; drag it on the preview too + Moves the crop up or down within the frame; drag it on the preview too Zoom keyframes over the sequence: double-click adds · drag moves · Delete removes · arrows nudge + Turns the picture upside down This frame already has a keyframe; select it on the curve to edit it Virtual-camera keyframes: zoom and framing at chosen frames, eased in between + Swaps left and right Select a keyframe on the curve first Moves the crop left or right inside the frame Moves the crop up or down inside the frame Remove the selected keyframe + Clears the crop, rotation, mirror, flip and straighten; keyframes stay + Nothing to reset: the whole frame is shown as shot + Turns the picture a quarter turn anticlockwise + Turns the picture a quarter turn clockwise + Quarter turns of the picture; the crop and the keyframes turn with it + Levels the horizon; the picture zooms in just enough to hide the corners Zoom of the selected keyframe; 1 shows the whole crop, more zooms in and softens Choose another sequence to edit; this one is saved first · Ctrl+O Frame-to-frame brightness change before and after the correction @@ -174,10 +185,12 @@ Frames per second of the video file Auto: the preset’s {0} fps Return to the preset’s frame rate - Output height in pixels; empty follows the width · Enter applies, Esc reverts + Height of the box the output fits in; empty follows the width · Enter applies, Esc reverts Open Jobs filtered on this sequence Include this preset when Batch queues the render Tokens: {date} {title} {preset} {codec} {width} {height} {fps} · Enter applies, Esc reverts + The encoder takes at most {0}, so the output is made smaller{0} the encoder's largest size as width×height + The preset's resolution fitted to the chosen aspect Render with {0}; editing a value makes it Custom Image quality; 95 looks lossless, lower makes smaller files Advisor pick: {0} @@ -189,7 +202,7 @@ The server does not have this sequence: upload it from the Server screen first Renders of a server sequence are made on the server and stay there Connect to the server first to send renders to it - Output width in pixels; empty uses the preset or the source · Enter applies, Esc reverts + Width of the box the output fits in; empty uses the preset or the source · Enter applies, Esc reverts Removes frame-to-frame brightness flicker; off keeps the camera’s own exposure Turns ISO, shutter and aperture steps into smooth ramps; off keeps the jumps Brightens or darkens the whole video after correction, in stops @@ -213,6 +226,9 @@ The library cannot be reached: the versions this PC keeps are listed The server cannot be reached: the versions this PC keeps are listed Make version {0} the project again (one step: Ctrl+Z takes it back); unsaved changes are saved as a version first{0} version number + Colour look of the video; the wipe compares it with the original + Colour look of every output frame, applied before the highlight knee + How much of the filter applies; 0 % leaves the picture as it is Adds blur along the motion like a slower shutter; costs optical flow on every frame Optical flow precision for blur and synthesised frames; Best is the slowest Target shutter angle; 180° is the film look, more smears moving things @@ -225,6 +241,8 @@ Not applicable: this format is lossless Needs the deep analysis: press Analyse Not applicable: used only by motion blur and interpolated timing + Not applicable: no filter is chosen + Not applicable: the crop fills the frame this way Not applicable: stabilisation is off Not applicable: stacking is off Open a project the library has for this sequence; Main holds its settings as they are @@ -253,6 +271,7 @@ Play the frames · Space; arrows step one frame Play ten seconds of the video’s frames with the current settings Wipe compare: original on the left, corrected on the right; drag the line + Drag to move · drag a handle to resize, aspect kept; Alt keeps the centre · arrows nudge, + and − resize · Esc cancels Dim what the output cuts (what I lose) Show the whole frame and darken what the output will cut Turn on Crop mask to choose between what you lose and how it will look @@ -687,6 +706,7 @@ Close without signing in · Esc Sent only to this server; Chronos keeps a session token, never the password Your user name on the server + This server's Chronos cannot read these settings; update it Video encoders the server can use on this PC: {0} No server found on this network yet; type its address Space you use on the server out of your quota diff --git a/i18n/it/Editor.it.resx b/i18n/it/Editor.it.resx index 6b899395..6d00e9b2 100644 --- a/i18n/it/Editor.it.resx +++ b/i18n/it/Editor.it.resx @@ -28,14 +28,24 @@ Ritaglio in basso Ritaglio a sinistra Ritaglio a destra + Dimensione ritaglio Ritaglio in alto + Ritaglio X + Ritaglio Y Fotogrammi chiave + Capovolgi Chiave {0} di {1} · {2} {0} chiave {0} chiavi + Specchia Posizione orizzontale Posizione verticale Rimuovi chiave + Ripristina inquadratura + Ruota a sinistra + Ruota a destra + Rotazione + Raddrizza Zoom Cambia sequenza copertura nuvolosa % @@ -77,6 +87,7 @@ Metti in coda In serie… Scegli cartella… + {0} (ridotta) Codec Colore Contenitore @@ -92,6 +103,7 @@ In serie Ancora nessun render Uscita · {0} + Dimensione uscita Preset di esportazione Qualità Qualità {0} @@ -172,6 +184,17 @@ Cronologia di {0} Versione {0} Apertura sequenza + Freddo + Sbiadito + Filtro + Aspetto + Mono + Tenue + Nessuno + Seppia + Intensità + Vivace + Caldo Taglio: pausa o vuoto Fotogramma chiave Salto di esposizione {0} EV @@ -216,6 +239,7 @@ Confronta Maschera ritaglio Risultato ritaglio + x {0}, y {1}, dimensione {2} Esci da schermo intero Schermo intero uscita {0} diff --git a/i18n/it/Errors.it.resx b/i18n/it/Errors.it.resx index 831798ef..92a126aa 100644 --- a/i18n/it/Errors.it.resx +++ b/i18n/it/Errors.it.resx @@ -19,6 +19,7 @@ Le impostazioni del progetto superano {0} MB; Chronos non può salvarle. {0} non è stato scaricato integro. Esportazioni non riuscite: {0} su {1}; vedi il registro del job. + Queste impostazioni richiedono un Chronos più recente. I nodi di rendering restituiscono un file per job; invia ogni preset di un gruppo come job a sé. I nodi di rendering restituiscono un file per job; le sequenze di immagini si renderizzano dove si trova l'archivio. Il job di rendering non ha impostazioni di esportazione valide. diff --git a/i18n/it/Export.it.resx b/i18n/it/Export.it.resx index 6f9dea5f..41518b1b 100644 --- a/i18n/it/Export.it.resx +++ b/i18n/it/Export.it.resx @@ -56,11 +56,14 @@ Il fotogramma {0} ({1}) non è decodificabile; escludilo o controlla il file. Il fotogramma chiave {0} non è valido ed è stato saltato. Compressione delle alte luci {0} fuori intervallo, ignorata. + Aspetto «{0}» sconosciuto; i colori restano come sono. Tutti i fotogrammi sono esclusi: non c'è nulla da renderizzare. Nessuna maschera cielo/terra; il deflicker usa l'intera immagine. La maschera cielo/terra è incerta (affidabilità {0}); il deflicker usa l'intera immagine. + La rotazione di {0}° non è un quarto di giro e viene ignorata. Vibrazioni forti: la stabilizzazione conserverebbe solo {0} dell'immagine, i bordi possono vedersi. Stabilizzazione non disponibile: troppo pochi dettagli da tracciare. + Raddrizzamento di {0}° fuori intervallo; si usa {1}°. Il contenitore non è adatto al codec; viene usato quello del codec. Codec sconosciuto; viene usato quello del preset. Frequenza sconosciuta; viene usata quella del preset. diff --git a/i18n/it/Server.it.resx b/i18n/it/Server.it.resx index aa0c1f11..feb40c17 100644 --- a/i18n/it/Server.it.resx +++ b/i18n/it/Server.it.resx @@ -162,13 +162,18 @@ Valori di esportazione Correzione esposizione Adatta alla durata + Capovolgimento Qualità del flusso Frequenza fotogrammi Fotogramma copertina Compressione alte luci Holy grail Keyframe camera + Aspetto + Filtro aspetto + Intensità aspetto manuale + Specchiatura Sfocatura di movimento Note disattivo @@ -177,10 +182,12 @@ Nome del file Valutazione Regioni + Rotazione Angolo otturatore Stabilizzazione Morbidezza stabilizzazione Stacking + Raddrizzamento Tag Rimappatura del tempo Modalità dei tempi diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index 46716672..fcfcce97 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -136,17 +136,28 @@ Torna alla Libreria È in corso un’analisi o un render di questa sequenza; le impostazioni attendono la fine Aggiunge una chiave al fotogramma corrente - Formato dell’uscita; un preset con dimensioni fisse usa il proprio + Proporzioni dell’uscita; la risoluzione del preset si adatta a esse (4K a 9:16 = 2160×3840) Centro orizzontale dell’inquadratura della chiave scelta Centro verticale dell’inquadratura della chiave scelta Taglia questa parte del fotogramma su quel lato; formato e posizione valgono poi dentro il ritaglio + Dimensione del ritaglio rispetto al più grande che le proporzioni consentono; si cambia anche trascinando una maniglia sull’anteprima + Sposta il ritaglio a sinistra o a destra nel fotogramma; si trascina anche sull’anteprima + Sposta il ritaglio in alto o in basso nel fotogramma; si trascina anche sull’anteprima Fotogrammi chiave dello zoom: doppio clic aggiunge · trascina sposta · Canc rimuove · le frecce spostano di poco + Capovolge l’immagine, scambiando alto e basso Questo fotogramma ha già un fotogramma chiave; selezionalo sulla curva per modificarlo Chiavi della camera virtuale: zoom e inquadratura in fotogrammi scelti, raccordati tra loro + Scambia sinistra e destra Seleziona prima un fotogramma chiave sulla curva Sposta il ritaglio a sinistra o a destra nel fotogramma Sposta il ritaglio in alto o in basso nel fotogramma Rimuove la chiave selezionata + Annulla ritaglio, rotazione, specchiatura, capovolgimento e raddrizzamento; le chiavi restano + Niente da ripristinare: si vede tutto il fotogramma come è stato scattato + Ruota l’immagine di un quarto di giro in senso antiorario + Ruota l’immagine di un quarto di giro in senso orario + Quarti di giro dell’immagine; il ritaglio e le chiavi girano con essa + Livella l’orizzonte; l’immagine si ingrandisce quanto basta a nascondere gli angoli Zoom della chiave scelta; 1 mostra tutto il ritaglio, di più ingrandisce e ammorbidisce Scegli un'altra sequenza da modificare; questa viene salvata prima · Ctrl+O Variazione di luminosità tra fotogrammi prima e dopo la correzione @@ -174,10 +185,12 @@ Fotogrammi al secondo del file video Auto: i {0} fps del preset Torna ai fotogrammi al secondo del preset - Altezza in pixel; vuoto segue la larghezza · Invio applica, Esc annulla + Altezza del riquadro in cui sta l’uscita; vuoto segue la larghezza · Invio applica, Esc annulla Apre Lavori filtrati su questa sequenza Include questo preset quando In serie mette in coda il render Segnaposto: {date} {title} {preset} {codec} {width} {height} {fps} · Invio applica, Esc annulla + L’encoder accetta al massimo {0}, quindi l’uscita viene ridotta + La risoluzione del preset adattata alle proporzioni scelte Renderizza con {0}; modificare un valore lo rende Personalizzato Qualità dell’immagine; 95 sembra senza perdite, meno fa file più piccoli Scelta del consulente: {0} @@ -189,7 +202,7 @@ Il server non ha questa sequenza: caricala prima dalla schermata Server I render di una sequenza del server si fanno sul server e restano lì Connettiti prima al server per inviargli i render - Larghezza in pixel; vuoto usa il preset o la sorgente · Invio applica, Esc annulla + Larghezza del riquadro in cui sta l’uscita; vuoto usa il preset o la sorgente · Invio applica, Esc annulla Elimina lo sfarfallio di luminosità tra fotogrammi; spento lascia l’esposizione della fotocamera Trasforma i salti di ISO, tempo e diaframma in rampe morbide; spento li lascia Schiarisce o scurisce tutto il video dopo la correzione, in stop @@ -213,6 +226,9 @@ La libreria non è raggiungibile: sono elencate le versioni che questo PC conserva Il server non è raggiungibile: sono elencate le versioni che questo PC conserva Rendi di nuovo la versione {0} il progetto (un passo: Ctrl+Z lo annulla); le modifiche non salvate diventano prima una versione + Aspetto cromatico del video; la tendina lo confronta con l’originale + Aspetto cromatico di ogni fotogramma in uscita, applicato prima della compressione delle alte luci + Quanto del filtro si applica; 0 % lascia l’immagine com’è Aggiunge mosso lungo il movimento come un tempo più lungo; richiede il flusso ottico su ogni fotogramma Precisione del flusso ottico per mosso e fotogrammi sintetici; Massima è la più lenta Angolo otturatore obiettivo; 180° è l’aspetto cinema, di più impasta ciò che si muove @@ -225,6 +241,8 @@ Non applicabile: questo formato è senza perdite Serve l’analisi approfondita: premi Analizza Non applicabile: serve solo al mosso e ai tempi interpolati + Non applicabile: nessun filtro scelto + Non applicabile: il ritaglio riempie il fotogramma in questa direzione Non applicabile: la stabilizzazione è spenta Non applicabile: lo stacking è spento Apri un progetto che la libreria ha per questa sequenza; Principale ne contiene le impostazioni attuali @@ -253,6 +271,7 @@ Riproduce i fotogrammi · Spazio; le frecce avanzano di uno Riproduce dieci secondi dei fotogrammi del video con le impostazioni attuali Confronto a tendina: originale a sinistra, corretto a destra; trascina la linea + Trascina per spostare · trascina una maniglia per ridimensionare a proporzioni bloccate; Alt tiene fermo il centro · le frecce spostano, + e − ridimensionano · Esc annulla Scurisce ciò che l’uscita taglia (cosa perdo) Mostra tutto il fotogramma e scurisce ciò che l’uscita taglierà Attiva Maschera ritaglio per scegliere tra cosa perdi e come apparirà @@ -685,6 +704,7 @@ Chiude senza accedere · Esc Inviata solo a questo server; Chronos conserva un token di sessione, mai la password Il tuo nome utente sul server + Il Chronos di questo server non legge queste impostazioni; aggiornalo Encoder video che il server può usare su questo PC: {0} Nessun server trovato ancora in questa rete; scrivi il suo indirizzo Spazio che usi sul server rispetto alla tua quota diff --git a/src/Chronos.App/Editor/EditPath.cs b/src/Chronos.App/Editor/EditPath.cs index 1fc869e8..2e700cb1 100644 --- a/src/Chronos.App/Editor/EditPath.cs +++ b/src/Chronos.App/Editor/EditPath.cs @@ -5,6 +5,7 @@ using Chronos.App.Jobs; using Chronos.Core.Advice; using Chronos.Core.Analysis; using Chronos.Core.Analysis.Deep; +using Chronos.Core.Imaging.Geometry; using Chronos.Core.Localization; using Chronos.Core.Model; using Chronos.Core.Project; @@ -223,13 +224,16 @@ public static class EditPath || (setting.IsAuto(project) && EditorSettings.Applies(setting, project, deep)); } - /// Values of the section set by hand that are not Auto settings: crop, offsets and camera moves; fit to a duration; the exposure offset. + /// + /// Values of the section set by hand that are not Auto settings: crop, offsets, orientation and camera moves; fit to a + /// duration; the exposure offset and the look. + /// private static bool HasHandValues(ProjectSettings project, AdvisorSection section) => section switch { - AdvisorSection.Camera => CropMargins.Of(project.Camera.Crop).Any(m => m > 0) || project.Camera.OffsetX != 0 || project.Camera.OffsetY != 0 - || project.Camera.Keyframes.Count > 0, + AdvisorSection.Camera => !CropFrame.IsWhole(project.Camera.Crop) || project.Camera.OffsetX != 0 || project.Camera.OffsetY != 0 + || project.Camera.Keyframes.Count > 0 || project.Camera.IsOriented, AdvisorSection.Timing => project.Timing.FitToSeconds is > 0, - AdvisorSection.Exposure => project.Exposure.ExposureOffsetEv != 0, + AdvisorSection.Exposure => project.Exposure.ExposureOffsetEv != 0 || project.Look is not null, _ => false, }; diff --git a/src/Chronos.App/Editor/PreviewRenderer.cs b/src/Chronos.App/Editor/PreviewRenderer.cs index 2f407b61..334361f4 100644 --- a/src/Chronos.App/Editor/PreviewRenderer.cs +++ b/src/Chronos.App/Editor/PreviewRenderer.cs @@ -58,7 +58,7 @@ public sealed class PreviewFrame(int index, ImageBuffer corrected, ImageBuffer o /// The corrected-frame preview through the render pipeline at preview size (BRIEF §12.3). The render pipeline has no /// single-frame entry point, so the per-frame steps of RenderRun are followed here: corrections from /// exactly as a render prepares them, then each frame through the render's exposure -/// stage, its single geometry warp and the highlight knee. Stacking and motion blur need neighbouring frames and are +/// stage, its single geometry warp and its finish (look, then highlight knee). Stacking and motion blur need neighbouring frames and are /// left to the render. /// /// Preparing is split so a slider never decodes the sequence again: a measuring preparation (luminance, colour means, @@ -282,7 +282,7 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou raw.Dispose(); raw = framed; } - if (request.Project.Exposure.HighlightKnee is > 0 and < 1 and var knee) ExposureProcessor.Apply(corrected, 0, null, knee); + FrameFinish.Apply(corrected, request.Project.Look, request.Project.Exposure.HighlightKnee); return (corrected, raw, request.Framing == PreviewFraming.Output ? null : plan); } catch diff --git a/src/Chronos.App/Server/SyncText.cs b/src/Chronos.App/Server/SyncText.cs index 0f6cce9f..a454f0bb 100644 --- a/src/Chronos.App/Server/SyncText.cs +++ b/src/Chronos.App/Server/SyncText.cs @@ -87,6 +87,13 @@ public static class SyncText ["camera.offsetX"] = "Server.Setting.CameraOffset", ["camera.offsetY"] = "Server.Setting.CameraOffset", ["camera.keyframes"] = "Server.Setting.Keyframes", + ["camera.rotate"] = "Server.Setting.Rotation", + ["camera.mirror"] = "Server.Setting.Mirror", + ["camera.flip"] = "Server.Setting.Flip", + ["camera.straighten"] = "Server.Setting.Straighten", + ["look"] = "Server.Setting.Look", + ["look.filter"] = "Server.Setting.LookFilter", + ["look.strength"] = "Server.Setting.LookStrength", ["stack.mode"] = "Server.Setting.Stacking", ["stack.length"] = "Server.Setting.TrailLength", ["export.preset"] = "Server.Setting.ExportPreset", diff --git a/src/Chronos.Core/Imaging/Color/LookFilter.cs b/src/Chronos.Core/Imaging/Color/LookFilter.cs new file mode 100644 index 00000000..3efc98e2 --- /dev/null +++ b/src/Chronos.Core/Imaging/Color/LookFilter.cs @@ -0,0 +1,31 @@ +namespace Chronos.Core.Imaging.Color; + +/// +/// The built-in colour looks (owner review 1, R6): parametric, so a server or a Docker image renders them without LUT +/// files. Each look is a linear-light 3×3 matrix, a contrast power about 0.18 and a lift, blended with the picture by its +/// strength; values are never clamped (the highlight knee that follows compresses any overshoot). Applied to output +/// frames only (), never seen by measuring, flow or stacking. +/// +public static class LookFilter +{ + /// The identity look's name. + public const string None = "none"; + + /// Every look this Chronos renders, in the order the editor lists them; names are lower case. + public static IReadOnlyList Names { get; } = [None, "mono", "sepia", "warm", "cool", "vivid", "muted", "fade"]; + + /// A name this Chronos renders: null (none) or one of (ordinal, case-sensitive). + public static bool IsKnown(string? name) => name is null || Names.Contains(name, StringComparer.Ordinal); + + /// + /// Applies the look at (0..1) to the colour planes of a + /// linear-light in place; a fourth (alpha) channel is left untouched. None, an unknown name and + /// a strength of 0 leave the image as it is. + /// + public static void Apply(ImageBuffer image, string? filter, double strength) + { + ArgumentNullException.ThrowIfNull(image); + if (filter is null or None || !(strength > 0) || !IsKnown(filter)) return; + // Every look renders as the identity until the looks are implemented. + } +} diff --git a/src/Chronos.Core/Imaging/Geometry/CropFrame.cs b/src/Chronos.Core/Imaging/Geometry/CropFrame.cs new file mode 100644 index 00000000..2ef76c67 --- /dev/null +++ b/src/Chronos.Core/Imaging/Geometry/CropFrame.cs @@ -0,0 +1,168 @@ +namespace Chronos.Core.Imaging.Geometry; + +/// The part of a crop box a pointer drags (owner review 1, R5): the inside moves it, a handle resizes it. +public enum CropHandle +{ + None, + + /// Inside the box: moves it. + Inside, + TopLeft, + Top, + TopRight, + Right, + BottomRight, + Bottom, + BottomLeft, + Left, +} + +/// +/// The crop box locked to the output proportions (owner review 1, R5), in normalised view-frame units ([0,1]² of the view +/// T, ). lockRatio is the box's width over its height in these units: the output +/// ratio × H'/W' (RenderGeometry.LockRatio). Every box returned keeps that ratio, lies inside [0,1]² and is at least +/// of . The editor writes the box itself to CameraSettings.Crop +/// with the offsets at 0, so returns it unchanged at render time. +/// +public static class CropFrame +{ + /// The smallest box, as a share of the largest one (per side). + public const double MinimumShare = 0.1; + + private static readonly RectD Whole = new(0, 0, 1, 1); + + /// The largest box of inside [0,1]², centred. + public static RectD Largest(double lockRatio) => AspectRatio.FitCrop(Whole, Checked(lockRatio)); + + /// + /// A stored crop as a rectangle: clamped to [0,1]² as the render reads it, the whole view for + /// null or an invalid crop (not four finite values, or too small). + /// + public static RectD Of(double[]? crop) + { + if (crop is not [var x0, var y0, var w0, var h0] || !double.IsFinite(x0 + y0 + w0 + h0)) return Whole; + var x = double.Clamp(x0, 0, 1); + var y = double.Clamp(y0, 0, 1); + var w = double.Min(w0, 1 - x); + var h = double.Min(h0, 1 - y); + return w <= 1e-3 || h <= 1e-3 ? Whole : new RectD(x, y, w, h); + } + + /// A box as CameraSettings.Crop; null for the whole view. + public static double[]? ToCrop(RectD box) => IsWhole(box) ? null : [box.X, box.Y, box.Width, box.Height]; + + /// The crop shows the whole view (null, invalid, or covering [0,1]²): nothing is cut. + public static bool IsWhole(double[]? crop) => IsWhole(Of(crop)); + + /// + /// The locked box an editor shows and edits for a stored crop: the largest box of inside it, + /// placed by the offsets as the render places it (). The first edit of a legacy free + /// crop with offsets bakes them in this way. + /// + public static RectD Locked(double[]? crop, double lockRatio, double offsetX = 0, double offsetY = 0) => + AspectRatio.FitCrop(Of(crop), Checked(lockRatio), double.IsFinite(offsetX) ? offsetX : 0, double.IsFinite(offsetY) ? offsetY : 0); + + /// + /// made valid: its centre kept, its size forced to (same area), + /// between the minimum and , then moved inside [0,1]². + /// + public static RectD Clamp(RectD box, double lockRatio) + { + var largest = Largest(lockRatio); + var area = double.IsFinite(box.Width * box.Height) && box.Width > 0 && box.Height > 0 ? box.Width * box.Height : largest.Width * largest.Height; + var height = double.Clamp(double.Sqrt(area / lockRatio), largest.Height * MinimumShare, largest.Height); + var width = double.Min(height * lockRatio, largest.Width); + height = width / lockRatio; + var cx = double.IsFinite(box.CenterX) ? box.CenterX : 0.5; + var cy = double.IsFinite(box.CenterY) ? box.CenterY : 0.5; + return Placed(cx - width / 2, cy - height / 2, width, height); + } + + /// moved by (, ), stopping at the edges of [0,1]². + public static RectD Move(RectD box, double dx, double dy) => Placed(box.X + dx, box.Y + dy, box.Width, box.Height); + + /// + /// resized by dragging to (, ): + /// a corner is anchored at the opposite corner, an edge at the opposite edge and stays centred on the other axis; with + /// (Alt) the centre stays. The ratio stays , the size between + /// the minimum and what fits in [0,1]² from the anchor. and + /// return . + /// + public static RectD ResizeFrom(RectD start, CropHandle handle, double x, double y, double lockRatio, bool aboutCentre = false) + { + Checked(lockRatio); + if (handle is CropHandle.None or CropHandle.Inside) return start; + // The anchor: the opposite corner or edge midpoint, or the centre; the handle's side signs (−1, 0, +1) per axis. + var (sx, sy) = handle switch + { + CropHandle.TopLeft => (-1, -1), + CropHandle.Top => (0, -1), + CropHandle.TopRight => (1, -1), + CropHandle.Right => (1, 0), + CropHandle.BottomRight => (1, 1), + CropHandle.Bottom => (0, 1), + CropHandle.BottomLeft => (-1, 1), + _ => (-1, 0), + }; + var ax = aboutCentre || sx == 0 ? start.CenterX : sx > 0 ? start.X : start.Right; + var ay = aboutCentre || sy == 0 ? start.CenterY : sy > 0 ? start.Y : start.Bottom; + var reach = aboutCentre ? 2 : 1; + // The height the pointer asks for along each moving axis; a corner takes the larger of the two. + var fromX = sx == 0 ? 0 : double.Max(0, sx * (x - ax)) * reach / lockRatio; + var fromY = sy == 0 ? 0 : double.Max(0, sy * (y - ay)) * reach; + var height = sx == 0 ? fromY : sy == 0 ? fromX : double.Max(fromX, fromY); + // The room around the anchor in each direction the box grows. + double RoomX() => sx == 0 || aboutCentre ? 2 * double.Min(ax, 1 - ax) : sx > 0 ? 1 - ax : ax; + double RoomY() => sy == 0 || aboutCentre ? 2 * double.Min(ay, 1 - ay) : sy > 0 ? 1 - ay : ay; + var largest = Largest(lockRatio); + var maxHeight = double.Min(double.Min(RoomY(), RoomX() / lockRatio), largest.Height); + height = double.Clamp(height, double.Min(largest.Height * MinimumShare, maxHeight), maxHeight); + var width = height * lockRatio; + var left = aboutCentre || sx == 0 ? ax - width / 2 : sx > 0 ? ax : ax - width; + var top = aboutCentre || sy == 0 ? ay - height / 2 : sy > 0 ? ay : ay - height; + return Placed(left, top, width, height); + } + + /// + /// for new proportions (an aspect change): the same centre, the same area where it fits, the new + /// ratio, kept inside [0,1]². + /// + public static RectD Refit(RectD box, double lockRatio) => Clamp(box, lockRatio); + + /// + /// The Camera step's rows for a box: its size as a share of (0.1..1), and its centre within the + /// slack per axis (−1 = left/top, 0 = centred, +1 = right/bottom; 0 where there is no slack). + /// + public static (double Size, double X, double Y) ToRows(RectD box, double lockRatio) + { + var largest = Largest(lockRatio); + var size = double.Clamp(box.Height / largest.Height, MinimumShare, 1); + static double Place(double start, double length) => 1 - length > 1e-9 ? double.Clamp(2 * start / (1 - length) - 1, -1, 1) : 0; + return (size, Place(box.X, box.Width), Place(box.Y, box.Height)); + } + + /// The box of the Camera step's rows (). + public static RectD FromRows(double size, double x, double y, double lockRatio) + { + var largest = Largest(lockRatio); + var share = double.Clamp(double.IsFinite(size) ? size : 1, MinimumShare, 1); + var (width, height) = (largest.Width * share, largest.Height * share); + static double Start(double place, double length) => (1 - length) * (1 + double.Clamp(double.IsFinite(place) ? place : 0, -1, 1)) / 2; + return new RectD(Start(x, width), Start(y, height), width, height); + } + + /// The view has room for the box to move along x () or y. + public static bool HasSlack(RectD box, bool horizontal) => (horizontal ? 1 - box.Width : 1 - box.Height) > 1e-9; + + private static bool IsWhole(RectD box) => box.X <= 0 && box.Y <= 0 && box.Right >= 1 && box.Bottom >= 1; + + /// A box of the given size moved inside [0,1]². + private static RectD Placed(double left, double top, double width, double height) => + new(double.Clamp(left, 0, double.Max(0, 1 - width)), double.Clamp(top, 0, double.Max(0, 1 - height)), width, height); + + private static double Checked(double lockRatio) + { + if (!(lockRatio > 0) || double.IsInfinity(lockRatio)) throw new ArgumentOutOfRangeException(nameof(lockRatio)); + return lockRatio; + } +} diff --git a/src/Chronos.Core/Imaging/Geometry/FrameOrientation.cs b/src/Chronos.Core/Imaging/Geometry/FrameOrientation.cs new file mode 100644 index 00000000..1fb2f6f4 --- /dev/null +++ b/src/Chronos.Core/Imaging/Geometry/FrameOrientation.cs @@ -0,0 +1,132 @@ +using Chronos.Core.Project; + +namespace Chronos.Core.Imaging.Geometry; + +/// +/// The view frame T of a camera (owner review 1, R6): the decoded (Exif-oriented, stabilised) frame of +/// × turned by quarter turns clockwise, then mirrored +/// and flipped in screen axes, then straightened by degrees clockwise about its centre and +/// magnified by so no border shows. is O = S · F · Q in +/// pixel-centre coordinates (); the quarter turns and the mirror/flip are exact integer matrices, so +/// an unstraightened view resamples to an exact permutation of the pixels. The crop and the keyframe centres are +/// normalised in T. Pixels are never turned after decode: the render folds into its single warp. +/// +public sealed record FrameOrientation +{ + /// The largest straighten angle in degrees, either way. + public const double MaxStraighten = 15; + + private FrameOrientation(int turns, bool mirror, bool flip, double straighten, int frameWidth, int frameHeight) + { + Turns = turns; + Mirror = mirror; + Flip = flip; + Straighten = straighten; + FrameWidth = frameWidth; + FrameHeight = frameHeight; + (ViewWidth, ViewHeight) = turns % 2 == 1 ? (frameHeight, frameWidth) : (frameWidth, frameHeight); + CoverZoom = CoverZoomOf(straighten, ViewWidth, ViewHeight); + FrameToView = Straightening(1) * MirrorFlip() * QuarterTurns(); + ViewToFrame = QuarterTurns().Invert() * MirrorFlip() * Straightening(-1); + } + + /// Quarter turns clockwise, 0..3. + public int Turns { get; } + + /// Left and right swapped after the turns. + public bool Mirror { get; } + + /// Top and bottom swapped after the turns. + public bool Flip { get; } + + /// Degrees clockwise, within ±. + public double Straighten { get; } + + /// The decoded frame's size in pixels. + public int FrameWidth { get; } + + public int FrameHeight { get; } + + /// The view frame's size in pixels: the frame's, swapped for an odd number of turns. + public int ViewWidth { get; } + + public int ViewHeight { get; } + + /// The straighten's cover zoom c = cos|θ| + max(W'/H', H'/W')·sin|θ| (1 without straighten); never stored. + public double CoverZoom { get; } + + /// Frame pixel-centre coordinates to view pixel-centre coordinates (O). + public Affine2D FrameToView { get; } + + /// View pixel-centre coordinates to frame pixel-centre coordinates (O⁻¹), for . + public Affine2D ViewToFrame { get; } + + /// No turn, mirror, flip or straighten: the view is the frame. + public bool IsIdentity => Turns == 0 && !Mirror && !Flip && Straighten == 0; + + /// The orientation of for a frame of the given size, its values normalised (, ). + public static FrameOrientation Of(CameraSettings camera, int frameWidth, int frameHeight) + { + ArgumentNullException.ThrowIfNull(camera); + return Of(camera.Rotate, camera.Mirror, camera.Flip, camera.Straighten, frameWidth, frameHeight); + } + + /// + public static FrameOrientation Of(int rotate, bool mirror, bool flip, double straighten, int frameWidth, int frameHeight) + { + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameWidth); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameHeight); + return new FrameOrientation(TurnsOf(rotate), mirror, flip, StraightenOf(straighten), frameWidth, frameHeight); + } + + /// The identity orientation of a frame of the given size. + public static FrameOrientation Identity(int frameWidth, int frameHeight) => Of(0, false, false, 0, frameWidth, frameHeight); + + /// The same orientation for a frame of another size (a decode at another long edge). + public FrameOrientation Resized(int frameWidth, int frameHeight) => frameWidth == FrameWidth && frameHeight == FrameHeight + ? this + : Of(Turns * 90, Mirror, Flip, Straighten, frameWidth, frameHeight); + + /// A rotation stored in degrees is a multiple of 90 (anything else renders as no turn). + public static bool IsValidRotate(int rotate) => rotate % 90 == 0; + + /// Quarter turns clockwise, 0..3, of a rotation in degrees; 0 when it is not a multiple of 90. + public static int TurnsOf(int rotate) => IsValidRotate(rotate) ? ((rotate / 90 % 4) + 4) % 4 : 0; + + /// A straighten angle as rendered: clamped to ±, 0 when not finite. + public static double StraightenOf(double degrees) => double.IsFinite(degrees) ? double.Clamp(degrees, -MaxStraighten, MaxStraighten) : 0; + + /// The angle is rendered as stored (finite and within ±). + public static bool IsValidStraighten(double degrees) => double.IsFinite(degrees) && double.Abs(degrees) <= MaxStraighten; + + /// + /// The smallest zoom about the centre at which a view of × + /// rotated by still covers the whole view: cos|θ| + max(W/H, H/W)·sin|θ|. + /// + public static double CoverZoomOf(double degrees, double viewWidth, double viewHeight) + { + if (degrees == 0) return 1; + var (sin, cos) = double.SinCos(double.Abs(degrees) * double.Pi / 180); + return cos + double.Max(viewWidth / viewHeight, viewHeight / viewWidth) * sin; + } + + /// Q: the quarter turns, frame → turned frame, exact. + private Affine2D QuarterTurns() => Turns switch + { + 1 => new Affine2D(0, -1, 1, 0, FrameHeight - 1, 0), + 2 => new Affine2D(-1, 0, 0, -1, FrameWidth - 1, FrameHeight - 1), + 3 => new Affine2D(0, 1, -1, 0, 0, FrameWidth - 1), + _ => Affine2D.Identity, + }; + + /// F: mirror and flip in the turned frame, exact (its own inverse). + private Affine2D MirrorFlip() => new(Mirror ? -1 : 1, 0, 0, Flip ? -1 : 1, Mirror ? ViewWidth - 1 : 0, Flip ? ViewHeight - 1 : 0); + + /// S ( 1) or S⁻¹ (−1): the straighten and its cover zoom about the view's centre. + private Affine2D Straightening(int direction) + { + if (Straighten == 0) return Affine2D.Identity; + var scale = direction > 0 ? CoverZoom : 1 / CoverZoom; + return Affine2D.About(Affine2D.Similarity(scale, direction * Straighten * double.Pi / 180, 0, 0), (ViewWidth - 1) / 2.0, (ViewHeight - 1) / 2.0); + } +} diff --git a/src/Chronos.Core/Imaging/Geometry/OrientationEdit.cs b/src/Chronos.Core/Imaging/Geometry/OrientationEdit.cs new file mode 100644 index 00000000..1328aeac --- /dev/null +++ b/src/Chronos.Core/Imaging/Geometry/OrientationEdit.cs @@ -0,0 +1,137 @@ +using Chronos.Core.Project; + +namespace Chronos.Core.Imaging.Geometry; + +/// One press of the Camera step's orientation controls, as the user sees the picture (owner review 1, R6). +public enum OrientationOp +{ + /// A quarter turn anticlockwise on screen. + RotateLeft, + + /// A quarter turn clockwise on screen. + RotateRight, + + /// Left and right swapped on screen. + Mirror, + + /// Top and bottom swapped on screen. + Flip, +} + +/// +/// Applies an orientation press to a camera so the content stays framed (owner review 1, R6): the picture as shown turns +/// or mirrors, and the crop, its offsets and the keyframe centres (normalised in the view frame) move with it. A quarter +/// turn transposes a non-square aspect (the manual value, or the Auto's advised one: 16:9 becomes 9:16); its stored +/// direction is inverted while exactly one of mirror and flip is set, as a mirror reverses the sense of a turn. Mirror and +/// flip toggle their member, negate the straighten (a mirrored level horizon stays level) and the keyframe rolls. Each +/// press is one edit (one undo step). +/// +public static class OrientationEdit +{ + /// The camera after . + public static CameraSettings Apply(CameraSettings camera, OrientationOp op) + { + ArgumentNullException.ThrowIfNull(camera); + var map = PointMap(op); + var turn = op is OrientationOp.RotateLeft or OrientationOp.RotateRight; + var mirrored = op is OrientationOp.Mirror or OrientationOp.Flip; + var result = camera with + { + Crop = camera.Crop is { Length: 4 } crop ? Remap(crop, op) : camera.Crop, + OffsetX = op switch + { + OrientationOp.RotateRight => Negated(camera.OffsetY), + OrientationOp.RotateLeft => camera.OffsetY, + OrientationOp.Mirror => Negated(camera.OffsetX), + _ => camera.OffsetX, + }, + OffsetY = op switch + { + OrientationOp.RotateRight => camera.OffsetX, + OrientationOp.RotateLeft => Negated(camera.OffsetX), + OrientationOp.Flip => Negated(camera.OffsetY), + _ => camera.OffsetY, + }, + Keyframes = [.. camera.Keyframes.Select(k => Remap(k, map, mirrored))], + Aspect = turn ? Transposed(camera.Aspect) : camera.Aspect, + }; + if (turn) + { + // A turn seen through one mirror is the opposite turn of the stored (unmirrored) picture. + var clockwise = (op == OrientationOp.RotateRight) ^ (camera.Mirror ^ camera.Flip); + var turns = (FrameOrientation.TurnsOf(camera.Rotate) + (clockwise ? 1 : 3)) % 4; + return result with { Rotate = turns * 90 }; + } + return op == OrientationOp.Mirror + ? result with { Mirror = !camera.Mirror, Straighten = Negated(camera.Straighten) } + : result with { Flip = !camera.Flip, Straighten = Negated(camera.Straighten) }; + } + + /// + /// The project after : , and the keyframes + /// parked on photos this copy does not hold () moved the same way. + /// + public static ProjectSettings Apply(ProjectSettings project, OrientationOp op) + { + ArgumentNullException.ThrowIfNull(project); + var map = PointMap(op); + var mirrored = op is OrientationOp.Mirror or OrientationOp.Flip; + return project with + { + Camera = Apply(project.Camera, op), + PendingFrames = project.PendingFrames is { } pending + ? [.. pending.Select(p => p.Keyframes is { Count: > 0 } keys ? p with { Keyframes = [.. keys.Select(k => Remap(k, map, mirrored))] } : p)] + : null, + }; + } + + /// A normalised point of the view before in the view after it. + public static (double X, double Y) MapPoint(double x, double y, OrientationOp op) => PointMap(op)(x, y); + + /// A normalised [x, y, w, h] crop of the view before in the view after it. + public static double[] Remap(double[] crop, OrientationOp op) + { + ArgumentNullException.ThrowIfNull(crop); + if (crop is not [var x, var y, var w, var h]) return crop; + return op switch + { + OrientationOp.RotateRight => [Clean(1 - y - h), x, h, w], + OrientationOp.RotateLeft => [y, Clean(1 - x - w), h, w], + OrientationOp.Mirror => [Clean(1 - x - w), y, w, h], + _ => [x, Clean(1 - y - h), w, h], + }; + } + + /// A non-square aspect transposed ("16:9" → "9:16"): the manual value and the advised one; "source" and text it cannot read stay. + public static Auto Transposed(Auto aspect) + { + ArgumentNullException.ThrowIfNull(aspect); + return aspect with { Manual = Transposed(aspect.Manual), AutoValue = Transposed(aspect.AutoValue) }; + } + + private static string? Transposed(string? text) => + AspectRatio.TryParse(text, out var ratio) && !ratio.IsSource && ratio.Width != ratio.Height ? AspectRatio.Custom(ratio.Height, ratio.Width).ToString() : text; + + private static Func PointMap(OrientationOp op) => op switch + { + OrientationOp.RotateRight => (x, y) => (Clean(1 - y), x), + OrientationOp.RotateLeft => (x, y) => (y, Clean(1 - x)), + OrientationOp.Mirror => (x, y) => (Clean(1 - x), y), + _ => (x, y) => (x, Clean(1 - y)), + }; + + /// + /// A remapped coordinate rounded to 12 decimals, so that undoing a press (four turns, two mirrors) gives back the stored + /// value and the same canonical text rather than one a rounding error away. + /// + private static double Clean(double value) => double.Round(value, 12); + + /// The value negated, never −0 (which JSON would write as "-0"). + private static double Negated(double value) => value == 0 ? 0 : -value; + + private static CameraKey Remap(CameraKey key, Func map, bool mirrored) + { + var (x, y) = map(key.CenterX, key.CenterY); + return key with { CenterX = x, CenterY = y, Rotation = mirrored ? Negated(key.Rotation) : key.Rotation }; + } +} diff --git a/src/Chronos.Core/Project/ProjectContent.cs b/src/Chronos.Core/Project/ProjectContent.cs index 3269106a..a9ba8266 100644 --- a/src/Chronos.Core/Project/ProjectContent.cs +++ b/src/Chronos.Core/Project/ProjectContent.cs @@ -238,17 +238,17 @@ public static class ProjectContent /// The settings format () a project's text declares; 1 when it says none or is not a project. public static int FormatOf(string? json) { - if (string.IsNullOrWhiteSpace(json)) return ProjectSettings.CurrentVersion; + if (string.IsNullOrWhiteSpace(json)) return ProjectSettings.BaseVersion; try { return JsonNode.Parse(json, new JsonNodeOptions { PropertyNameCaseInsensitive = true }) is JsonObject project && project["version"] is JsonValue value && value.TryGetValue(out var version) && version > 0 ? version - : ProjectSettings.CurrentVersion; + : ProjectSettings.BaseVersion; } catch (Exception ex) when (ex is JsonException or ArgumentException) { - return ProjectSettings.CurrentVersion; + return ProjectSettings.BaseVersion; } } diff --git a/src/Chronos.Core/Project/ProjectSettings.cs b/src/Chronos.Core/Project/ProjectSettings.cs index 2654249c..c2a27cf7 100644 --- a/src/Chronos.Core/Project/ProjectSettings.cs +++ b/src/Chronos.Core/Project/ProjectSettings.cs @@ -164,16 +164,59 @@ public sealed record MotionSettings public sealed record CameraSettings { - /// Normalised crop (0..1) or null for the full frame. + /// + /// Normalised [x, y, width, height] of the view frame (oriented, straightened and cover-zoomed: see + /// ), or null for the whole view. The editor writes the box locked to with + /// the offsets at 0; the render fits any other rectangle to the aspect. + /// public double[]? Crop { get; init; } - /// "source", "16:9", "21:9", "4:3", "3:2", "1:1", "9:16", "4:5" or "w:h". + /// + /// The output proportions: "source", "16:9", "21:9", "4:3", "3:2", "1:1", "9:16", "4:5" or "w:h". A preset of a fixed + /// size adapts its size to them (4K at 9:16 = 2160×3840); "source" keeps the preset's own. + /// public Auto Aspect { get; init; } = new(); + /// Placement of the aspect-fitted crop inside , −1..1 per axis; 0 for a crop the editor wrote. public double OffsetX { get; init; } + + /// public double OffsetY { get; init; } + + /// Virtual-camera keyframes; their centres are normalised in the view frame, like . public IReadOnlyList Keyframes { get; init; } = []; + /// + /// Quarter turns of the picture in degrees clockwise (0, 90, 180 or 270), after the Exif orientation applied at decode. + /// A value that is not a multiple of 90 renders as 0 (Export.Render.RotationIgnored). Settings format 2. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int Rotate { get; init; } + + /// Left and right swapped, in screen axes after . Settings format 2. + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool Mirror { get; init; } + + /// Top and bottom swapped, in screen axes after . Settings format 2. + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool Flip { get; init; } + + /// + /// Free-angle levelling in degrees, positive clockwise, after and , with an + /// automatic cover zoom (never stored) that never shows a border. Clamped to ±15, a value that is not finite counting as + /// 0 (Export.Render.StraightenClamped). Settings format 2. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public double Straighten { get; init; } + + /// Quarter turns clockwise, 0..3; meaningful only when is a multiple of 90. + [JsonIgnore] + public int Turns => ((Rotate / 90 % 4) + 4) % 4; + + /// A turn, mirror, flip or straighten is set: the view frame differs from the decoded frame. + [JsonIgnore] + public bool IsOriented => Rotate % 360 != 0 || Mirror || Flip || Straighten != 0; + /// Members this Chronos does not know (written by a newer one): kept as they are, so they survive a round trip. [JsonExtensionData] public Dictionary? Extra { get; set; } @@ -240,13 +283,50 @@ public sealed record ExportSettings public Dictionary? Extra { get; set; } } +/// +/// The colour look of a render (owner review 1, R6): a built-in parametric filter blended by its strength, applied to +/// every output frame in linear light before the highlight knee. is null for none. +/// +public sealed record LookSettings +{ + /// + /// The filter's name: null or "none", "mono", "sepia", "warm", "cool", "vivid", "muted" or "fade" + /// (LookFilter.Names). A text, not an enum, so a newer Chronos can add looks; one this Chronos does not know + /// renders as none (Export.Render.LookIgnored). + /// + public string? Filter { get; init; } + + /// Share of the filter applied, 0..1; null for 1. + public double? Strength { get; init; } + + /// The look leaves the picture as it is. + [JsonIgnore] + public bool IsIdentity => Filter is null or "none" || Strength is <= 0; + + /// Members this Chronos does not know (written by a newer one): kept as they are, so they survive a round trip. + [JsonExtensionData] + public Dictionary? Extra { get; set; } +} + /// /// The "project" of a sequence (.chronos/project.json, BRIEF §7): every render decision. Originals are /// never modified; all edits live here. /// +/// +/// The settings format () is conditional: writes the lowest format that renders +/// the same (), so a project that uses nothing newer keeps format 1, its canonical text and its +/// hash, and older builds read it as before. Rules for a member added later: one that changes pixels and that the previous +/// format would ignore raises the written format only while it is used; it is declared after the existing members of its +/// section (before Extra) and omitted at its default, so an older build keeps it in Extra and writes it +/// back in the same place; a list of choices that may grow is a text, never an enum. +/// public sealed record ProjectSettings { - public const int CurrentVersion = 1; + /// The highest settings format this Chronos reads; a project of a higher one opens read-only (). + public const int CurrentVersion = 2; + + /// The format of a project that uses nothing added since the first one, which most projects are written as. + public const int BaseVersion = 1; /// Layout of a project edited as JSON (): indented like . private static readonly JsonSerializerOptions IndentedJson = new() { WriteIndented = true }; @@ -254,7 +334,8 @@ public sealed record ProjectSettings /// Member names as a project edited as JSON reads them (an older or hand-written file may use any casing). private static readonly JsonNodeOptions CaseInsensitive = new() { PropertyNameCaseInsensitive = true }; - public int Version { get; init; } = CurrentVersion; + /// The settings format read; writes . + public int Version { get; init; } = BaseVersion; public TimingSettings Timing { get; init; } = new(); public ExposureSettings Exposure { get; init; } = new(); public MotionSettings Motion { get; init; } = new(); @@ -274,6 +355,9 @@ public sealed record ProjectSettings /// public IReadOnlyList? PendingFrames { get; init; } + /// The colour look (owner review 1, R6); null for none, which the editor writes whenever the look is the identity. + public LookSettings? Look { get; init; } + /// The hero waits for its photo, so advice does not choose one meanwhile. [JsonIgnore] public bool HeroPending => PendingFrames?.Any(p => p.Hero) == true; @@ -292,7 +376,22 @@ public sealed record ProjectSettings [JsonIgnore] public bool IsNewerFormat => Version > CurrentVersion; - public string ToJson() => JsonSerializer.Serialize(this, ProjectJson.Default.ProjectSettings); + /// + /// The lowest settings format that renders these settings the same: 2 while a turn, mirror, flip or straighten + /// () or a look other than the identity is set, otherwise . + /// + [JsonIgnore] + public int RequiredFormat => Camera.IsOriented || Look is { IsIdentity: false } ? 2 : BaseVersion; + + /// The format writes: , or a newer format read, kept as it is. + [JsonIgnore] + public int WrittenFormat => IsNewerFormat ? Version : RequiredFormat; + + /// + /// The settings as JSON, stamped with . Every serialisation of a project goes through here, + /// so the version written always matches the members used. + /// + public string ToJson() => JsonSerializer.Serialize(Version == WrittenFormat ? this : this with { Version = WrittenFormat }, ProjectJson.Default.ProjectSettings); /// /// Reads a project; members missing from (an API client's partial settings, an older file) diff --git a/src/Chronos.Core/Render/Diagnostics/SelfTest.cs b/src/Chronos.Core/Render/Diagnostics/SelfTest.cs index f18432fb..b50854c0 100644 --- a/src/Chronos.Core/Render/Diagnostics/SelfTest.cs +++ b/src/Chronos.Core/Render/Diagnostics/SelfTest.cs @@ -50,7 +50,8 @@ public sealed record SelfTestOptions /// public static partial class SelfTest { - public static IReadOnlyList Checks { get; } = [.. PlanChecks(), .. ExportChecks(), .. CodecChecks(), .. RenderChecks(), .. ProcessingChecks(), .. RobustnessChecks()]; + public static IReadOnlyList Checks { get; } = [.. PlanChecks(), .. ExportChecks(), .. CodecChecks(), .. RenderChecks(), .. ProcessingChecks(), .. GeometryChecks(), + .. ColourChecks(), .. RobustnessChecks()]; public static async Task> RunAsync(SelfTestOptions? options = null, IProgress? progress = null, CancellationToken cancellationToken = default) diff --git a/src/Chronos.Core/Render/Diagnostics/SelfTestColourChecks.cs b/src/Chronos.Core/Render/Diagnostics/SelfTestColourChecks.cs new file mode 100644 index 00000000..d8f4761d --- /dev/null +++ b/src/Chronos.Core/Render/Diagnostics/SelfTestColourChecks.cs @@ -0,0 +1,7 @@ +namespace Chronos.Core.Render.Diagnostics; + +/// Colour look checks (owner review 1, R6). +public static partial class SelfTest +{ + private static IEnumerable ColourChecks() => []; +} diff --git a/src/Chronos.Core/Render/Diagnostics/SelfTestGeometryChecks.cs b/src/Chronos.Core/Render/Diagnostics/SelfTestGeometryChecks.cs new file mode 100644 index 00000000..17e4c7ad --- /dev/null +++ b/src/Chronos.Core/Render/Diagnostics/SelfTestGeometryChecks.cs @@ -0,0 +1,7 @@ +namespace Chronos.Core.Render.Diagnostics; + +/// Orientation, straighten and output-proportion checks (owner review 1, R5/R6). +public static partial class SelfTest +{ + private static IEnumerable GeometryChecks() => []; +} diff --git a/src/Chronos.Core/Render/FrameFinish.cs b/src/Chronos.Core/Render/FrameFinish.cs new file mode 100644 index 00000000..757267ed --- /dev/null +++ b/src/Chronos.Core/Render/FrameFinish.cs @@ -0,0 +1,61 @@ +using System.Globalization; +using Chronos.Core.Analysis; +using Chronos.Core.Imaging; +using Chronos.Core.Imaging.Color; +using Chronos.Core.Project; + +namespace Chronos.Core.Render; + +/// +/// The last pixel step of every output frame (owner review 1, R6), shared by the render, the editor's preview, the server +/// and the render nodes: the colour look () and then the highlight knee, in linear light, after +/// stacking, interpolation and motion blur and before the encoder. The knee comes last so it compresses any overshoot the +/// look leaves. Measuring, flow and stacking never see either. +/// +public static class FrameFinish +{ + /// + /// The knee a render applies: when it lies in (0, 1), else none, with + /// Export.Render.KneeIgnored added to for a value out of range. + /// + public static double? Knee(double? highlightKnee, ICollection? warnings = null) + { + if (highlightKnee is not { } knee) return null; + if (knee is > 0 and < 1) return knee; + warnings?.Add(new RenderWarning("Export.Render.KneeIgnored", knee.ToString(CultureInfo.InvariantCulture))); + return null; + } + + /// + /// The look a render applies: null for none, the identity, or a filter this Chronos does not know, which adds + /// Export.Render.LookIgnored to . + /// + public static LookSettings? Look(LookSettings? look, ICollection? warnings = null) + { + if (look is null || look.IsIdentity) return null; + if (LookFilter.IsKnown(look.Filter)) return look; + warnings?.Add(new RenderWarning("Export.Render.LookIgnored", look.Filter ?? string.Empty)); + return null; + } + + /// The share of a look applied: its strength clamped to 0..1, 1 when not given (or not finite). + public static double Strength(LookSettings look) + { + ArgumentNullException.ThrowIfNull(look); + return look.Strength is { } strength && double.IsFinite(strength) ? double.Clamp(strength, 0, 1) : 1; + } + + /// Neither a look nor a knee would change a frame. + public static bool IsIdentity(LookSettings? look, double? knee) => (look is null || look.IsIdentity || !LookFilter.IsKnown(look.Filter)) && knee is not (> 0 and < 1); + + /// + /// Finishes a linear-light output in place: (none when null, the + /// identity or unknown), then the soft highlight knee when lies in (0, 1). + /// + public static void Apply(ImageBuffer frame, LookSettings? look, double? knee) + { + ArgumentNullException.ThrowIfNull(frame); + if (look is { IsIdentity: false } && LookFilter.IsKnown(look.Filter)) LookFilter.Apply(frame, look.Filter, Strength(look)); + if (knee is > 0 and < 1 and var k) ExposureProcessor.Apply(frame, 0, null, k); + } +} diff --git a/src/Chronos.Core/Render/RenderGeometry.cs b/src/Chronos.Core/Render/RenderGeometry.cs index a8db7400..f684951c 100644 --- a/src/Chronos.Core/Render/RenderGeometry.cs +++ b/src/Chronos.Core/Render/RenderGeometry.cs @@ -28,8 +28,10 @@ public sealed class RenderGeometry private readonly int _maxWorkingLongEdge; private RenderGeometry(VirtualCamera? camera, RectD crop, double offsetX, double offsetY, double stabilizationZoom, int sourceWidth, int sourceHeight, - int outputWidth, int outputHeight, double fittedWidth, double fittedHeight, double maxZoom, int maxWorkingLongEdge, IReadOnlyList warnings) + int outputWidth, int outputHeight, double fittedWidth, double fittedHeight, double maxZoom, int maxWorkingLongEdge, IReadOnlyList warnings, + double outputRatio) { + OutputRatio = outputRatio; _camera = camera; _crop = crop; _offsetX = offsetX; @@ -51,6 +53,30 @@ public sealed class RenderGeometry public int OutputWidth { get; } public int OutputHeight { get; } + /// + /// Width of the view frame T at full resolution (): the source turned, mirrored and + /// straightened. and the keyframe centres are normalised in it. + /// + public int ViewWidth => SourceWidth; + + /// + public int ViewHeight => SourceHeight; + + /// The output ratio (width / height) the crop is fitted to (), before rounding to whole pixels. + public double OutputRatio { get; } + + /// + /// The crop box's width over its height in normalised view units ( × / + /// ): the lock ratio of . + /// + public double LockRatio => OutputRatio * ViewHeight / ViewWidth; + + /// + /// The crop the editor shows and edits, normalised in the view frame and the same on every frame: the stored crop + /// fitted to the output ratio and placed by the offsets (). + /// + public RectD EditableCrop => AspectRatio.FitCrop(_crop, LockRatio, _offsetX, _offsetY); + /// Remarks about ignored camera values. public IReadOnlyList Warnings { get; } @@ -112,14 +138,14 @@ public sealed class RenderGeometry var cameraPath = Camera(camera.Keyframes, warnings); var maxZoom = (cameraPath?.Keyframes.Max(k => k.Zoom) ?? 1) * stabilizationZoom; return new RenderGeometry(cameraPath, crop, camera.OffsetX, camera.OffsetY, stabilizationZoom, sourceWidth, sourceHeight, width, height, - fitted.Width, fitted.Height, maxZoom, maxWorkingLongEdge, warnings); + fitted.Width, fitted.Height, maxZoom, maxWorkingLongEdge, warnings, ratio); } /// The same geometry rendering into a different output size (e.g. capped by the encoder). public RenderGeometry WithOutputSize(int width, int height) => width == OutputWidth && height == OutputHeight ? this : new RenderGeometry(_camera, _crop, _offsetX, _offsetY, _stabilizationZoom, SourceWidth, SourceHeight, width, height, _fittedWidth, _fittedHeight, - _maxZoom, _maxWorkingLongEdge, Warnings); + _maxZoom, _maxWorkingLongEdge, Warnings, OutputRatio); /// Camera pose at a (fractional) source position, including the stabilisation zoom. public CameraState PoseAt(double sourcePosition) @@ -146,6 +172,62 @@ public sealed class RenderGeometry }; } + /// + /// The view frame→decoded frame map (O⁻¹, ) for a frame of + /// × pixels, without stabilisation: what maps overlays + /// drawn in frame pixels (the horizon, the region mask) into the view through its inverse. + /// + public Affine2D ViewToFrame(int frameWidth, int frameHeight) + { + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameWidth); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameHeight); + return Affine2D.Identity; + } + + /// + /// The whole view frame of one decoded frame at × + /// pixels, without crop, camera pose or stabilisation: the editor's Source framing of an oriented camera. + /// + public GeometrySettings ViewFor(int frameWidth, int frameHeight, int outputWidth, int outputHeight) + { + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(outputWidth); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(outputHeight); + return new GeometrySettings + { + Aspect = AspectRatio.Source, + OutputWidth = outputWidth, + OutputHeight = outputHeight, + Warp = ViewToFrame(frameWidth, frameHeight), + Border = BorderMode.Clamp, + }; + } + + /// + /// The footprint of a planned output frame ( of on a frame of + /// ×) in the view frame: the bounding box of its warped + /// corners, normalised and clamped to [0,1]²; the whole view without a plan. The Export step's crop mask. + /// + public RectD FootprintInView(GeometryPlan? plan, int frameWidth, int frameHeight) + { + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameWidth); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameHeight); + if (plan is not { } p) return new RectD(0, 0, 1, 1); + var toView = ViewToFrame(frameWidth, frameHeight).Invert() * p.OutputToSource; + double left = double.MaxValue, top = double.MaxValue, right = double.MinValue, bottom = double.MinValue; + foreach (var (u, v) in new[] { (-0.5, -0.5), (p.OutputWidth - 0.5, -0.5), (-0.5, p.OutputHeight - 0.5), (p.OutputWidth - 0.5, p.OutputHeight - 0.5) }) + { + var (x, y) = toView.Apply(u, v); + (left, top, right, bottom) = (double.Min(left, x + 0.5), double.Min(top, y + 0.5), double.Max(right, x + 0.5), double.Max(bottom, y + 0.5)); + } + var (viewWidth, viewHeight) = ViewSizeOf(frameWidth, frameHeight); + left = double.Clamp(left / viewWidth, 0, 1); + top = double.Clamp(top / viewHeight, 0, 1); + return new RectD(left, top, double.Clamp(right / viewWidth, 0, 1) - left, double.Clamp(bottom / viewHeight, 0, 1) - top); + } + + /// The view frame's size for a decoded frame of the given size. + private static (int Width, int Height) ViewSizeOf(int frameWidth, int frameHeight) => (frameWidth, frameHeight); + private static RectD NormalisedCrop(double[]? crop, List warnings) { var full = new RectD(0, 0, 1, 1); diff --git a/src/Chronos.Core/Render/RenderPipeline.cs b/src/Chronos.Core/Render/RenderPipeline.cs index 0e447342..1728a7f9 100644 --- a/src/Chronos.Core/Render/RenderPipeline.cs +++ b/src/Chronos.Core/Render/RenderPipeline.cs @@ -16,7 +16,7 @@ namespace Chronos.Core.Render; /// at the working size; per-frame exposure corrections (deflicker, holy grail, white /// balance, regions) are applied; stabilisation, virtual camera and crop are resampled once to the output size; /// fractional positions are synthesised from the bidirectional flow; motion blur follows the flow with shutter-angle -/// composition; stacking (median, mean, star trails) and the highlight knee come last, then the encoder. Encoding of a +/// composition; stacking (median, mean, star trails) and the finish (look, then highlight knee: ) come last, then the encoder. Encoding of a /// frame overlaps the processing of the next. Cancellation and failures leave no output behind (sessions delete their /// partial files on dispose) and every background task is awaited, so exceptions surface exactly once. /// @@ -111,7 +111,8 @@ internal sealed class RenderRun : IDisposable private readonly List _warnings = []; private readonly Stopwatch _clock = new(); private readonly int _workingEdge; - private readonly float? _knee; + private readonly double? _knee; + private readonly LookSettings? _look; private readonly double _targetShutter; private readonly FlowQuality _flowQuality; private OpticalFlowEngine? _flowEngine; @@ -131,12 +132,8 @@ internal sealed class RenderRun : IDisposable _geometry = setup.Geometry; _prepared = new PreparedFrameCache(int.Max(3, options.CacheFrames)); _workingEdge = _geometry.WorkingLongEdge; - var exposure = input.Project.Exposure; - if (exposure.HighlightKnee is { } knee) - { - if (knee is > 0 and < 1) _knee = (float)knee; - else _warnings.Add(new RenderWarning("Export.Render.KneeIgnored", knee.ToString(CultureInfo.InvariantCulture))); - } + _knee = FrameFinish.Knee(input.Project.Exposure.HighlightKnee, _warnings); + _look = FrameFinish.Look(input.Project.Look, _warnings); var motion = input.Project.Motion; _targetShutter = double.Clamp(motion.TargetShutterAngle.Resolve(180.0), 0, 360); _flowQuality = motion.FlowQuality.Resolve(options.DefaultFlowQuality) switch @@ -403,14 +400,14 @@ internal sealed class RenderRun : IDisposable if (ev != 0 || (gains is { } g && g != ChannelGains.Identity)) ExposureProcessor.Apply(frame, ev, gains); } - /// Applies the knee and hands the frame to the encoder once the previous frame is encoded; owns . + /// Finishes the frame (look, then knee) and hands it to the encoder once the previous frame is encoded; owns . private async Task EmitAsync(ImageBuffer frame, long duration90k) { ImageBuffer? preview = null; try { await FlushEncodingAsync().ConfigureAwait(false); - if (_knee is { } knee) ExposureProcessor.Apply(frame, 0, null, knee); + FrameFinish.Apply(frame, _look, _knee); _done++; if (_options.PreviewInterval > 0 && (_done - 1) % _options.PreviewInterval == 0) preview = Resampler.Thumbnail(frame, _options.PreviewLongEdge); } diff --git a/src/Chronos.Core/Render/RenderRules.cs b/src/Chronos.Core/Render/RenderRules.cs new file mode 100644 index 00000000..bd76b77f --- /dev/null +++ b/src/Chronos.Core/Render/RenderRules.cs @@ -0,0 +1,32 @@ +using Chronos.Core.Export; +using Chronos.Core.Project; + +namespace Chronos.Core.Render; + +/// +/// What a render needs of the program that runs it (owner review 1, phase 4): the settings format a render node or server +/// must read to render a job as this Chronos would. Computed for routing and gating only, never written into the settings. +/// +public static class RenderRules +{ + /// + /// The settings format a render of with on a source of the given + /// (Exif-oriented) size needs: the format the settings are written in (), and + /// at least 2 when the chosen proportions change a fixed-size preset's size (), which a format-1 + /// program would render at the preset's own ratio. + /// + public static int RequiredFormat(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight) + { + ArgumentNullException.ThrowIfNull(settings); + ArgumentNullException.ThrowIfNull(export); + var format = settings.WrittenFormat; + if (export.Width > 0 && export.Height > 0 && sourceWidth > 0 && sourceHeight > 0 && !RenderSize.IsSource(settings.Camera) + && RenderSize.Of(settings.Camera, export, sourceWidth, sourceHeight) != PresetSize(export)) + format = int.Max(format, 2); + return format; + } + + /// A fixed-size preset's size as a format-1 program renders it (even for codecs that are not managed). + private static (int Width, int Height) PresetSize(ResolvedExport export) => + RenderSize.Of(new CameraSettings(), export, 1, 1); +} diff --git a/src/Chronos.Core/Render/RenderSize.cs b/src/Chronos.Core/Render/RenderSize.cs new file mode 100644 index 00000000..edf0c6b4 --- /dev/null +++ b/src/Chronos.Core/Render/RenderSize.cs @@ -0,0 +1,96 @@ +using Chronos.Core.Export; +using Chronos.Core.Imaging.Geometry; +using Chronos.Core.Project; +using Chronos.Core.Video; + +namespace Chronos.Core.Render; + +/// +/// The output size of a render (owner review 1, R5: "the chosen proportions win"), before the encoder caps it +/// (): one pure function shared by the render (), the editor's +/// Export step and the server's job routing. +/// +/// Fixed-size preset, aspect not "source"The aspect fitted in the preset's box, the box turned to portrait for a ratio below 1 (): 4K at 9:16 = 2160×3840. +/// Fixed-size preset, "source"The preset's size. +/// One side givenThe other side from the ratio. +/// No side givenThe aspect-fitted crop of the view, scaled down to the decode cap. +/// +/// Sizes are made even for codecs that are not managed (H.264, HEVC, AV1), and at least 2 (1 for managed codecs). +/// +public static class RenderSize +{ + /// The output size of for on a source of the given Exif-oriented size. + /// Decode-size cap (0 = none); it also caps source-sized outputs, as in . + public static (int Width, int Height) Of(CameraSettings camera, ResolvedExport export, int sourceWidth, int sourceHeight, int maxWorkingLongEdge = 0) + { + ArgumentNullException.ThrowIfNull(camera); + ArgumentNullException.ThrowIfNull(export); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(sourceWidth); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(sourceHeight); + var ratio = Ratio(camera, export, sourceWidth, sourceHeight); + int width, height; + if (export.Width > 0 && export.Height > 0) (width, height) = IsSource(camera) ? (export.Width, export.Height) : Adapt(export.Width, export.Height, ratio); + else if (export.Width > 0) (width, height) = (export.Width, (int)double.Round(export.Width / ratio)); + else if (export.Height > 0) (width, height) = ((int)double.Round(export.Height * ratio), export.Height); + else + { + var (viewWidth, viewHeight) = ViewSize(camera, sourceWidth, sourceHeight); + var crop = CropFrame.Of(camera.Crop); + var fitted = AspectRatio.FitCrop(new RectD(crop.X * viewWidth, crop.Y * viewHeight, crop.Width * viewWidth, crop.Height * viewHeight), ratio, + camera.OffsetX, camera.OffsetY); + var scale = maxWorkingLongEdge > 0 ? double.Min(1, maxWorkingLongEdge / double.Max(fitted.Width, fitted.Height)) : 1; + (width, height) = ((int)double.Round(fitted.Width * scale), (int)double.Round(fitted.Height * scale)); + } + var managed = VideoCodecInfo.IsManaged(export.Codec); + if (!managed) + { + width &= ~1; + height &= ~1; + } + return (int.Max(managed ? 1 : 2, width), int.Max(managed ? 1 : 2, height)); + } + + /// + /// The output ratio (width / height) the crop is fitted to: the aspect's, or for "source" (and an aspect that cannot be + /// read) the fixed-size preset's ratio, else the view's (the source turned by ). + /// + public static double Ratio(CameraSettings camera, ResolvedExport export, int sourceWidth, int sourceHeight) + { + ArgumentNullException.ThrowIfNull(camera); + ArgumentNullException.ThrowIfNull(export); + if (Aspect(camera) is { IsSource: false } aspect) return aspect.Width / (double)aspect.Height; + if (export.Width > 0 && export.Height > 0) return export.Width / (double)export.Height; + var (viewWidth, viewHeight) = ViewSize(camera, sourceWidth, sourceHeight); + return viewWidth / (double)viewHeight; + } + + /// The view frame's size for a source of the given size: swapped for an odd number of quarter turns. + public static (int Width, int Height) ViewSize(CameraSettings camera, int sourceWidth, int sourceHeight) + { + ArgumentNullException.ThrowIfNull(camera); + return FrameOrientation.TurnsOf(camera.Rotate) % 2 == 1 ? (sourceHeight, sourceWidth) : (sourceWidth, sourceHeight); + } + + /// + /// The largest size of inside the box × + /// turned to landscape for a ratio of 1 or more and to portrait below 1, rounded to whole pixels: 3840×2160 gives + /// 2160×3840 at 9:16, 2160×2160 at 1:1, 2160×2700 at 4:5 and 3840×1646 at 21:9; 1080×1920 gives 1920×1080 at 16:9. + /// + public static (int Width, int Height) Adapt(int boxWidth, int boxHeight, double ratio) + { + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(boxWidth); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(boxHeight); + if (!(ratio > 0) || double.IsInfinity(ratio)) throw new ArgumentOutOfRangeException(nameof(ratio)); + var (longEdge, shortEdge) = (int.Max(boxWidth, boxHeight), int.Min(boxWidth, boxHeight)); + var (width, height) = ratio < 1 ? (shortEdge, longEdge) : (longEdge, shortEdge); + return width / (double)height > ratio + ? (int.Max(1, (int)double.Round(height * ratio)), height) + : (width, int.Max(1, (int)double.Round(width / ratio))); + } + + /// The camera's aspect resolves to "source" (or to text that cannot be read, which renders as source). + public static bool IsSource(CameraSettings camera) => Aspect(camera) is not { IsSource: false }; + + private static AspectRatio? Aspect(CameraSettings camera) => + AspectRatio.TryParse(camera.Aspect.Resolve("source"), out var aspect) ? aspect : null; +} diff --git a/src/Chronos.Protocol/Dtos.cs b/src/Chronos.Protocol/Dtos.cs index 4976f1a2..cfd8fb17 100644 --- a/src/Chronos.Protocol/Dtos.cs +++ b/src/Chronos.Protocol/Dtos.cs @@ -13,6 +13,10 @@ public sealed record ServerLimits(long MaxUploadBytes, int ChunkSizeBytes, int P /// File extensions the archive files as photos (lower case, no dot): the admin panel's upload dialog offers and sends only /// these (owner review 2, R3). Null from servers that do not announce them. /// +/// +/// The highest project settings format the server reads and renders (ProjectSettings.CurrentVersion, owner review 1, +/// phase 4); null from an older server, which reads format 1 only. The desktop holds back a push or a render that needs more. +/// public sealed record ServerInfo( string Name, string Version, @@ -21,7 +25,8 @@ public sealed record ServerInfo( string? TlsFingerprint, IReadOnlyList Formats, ServerLimits Limits, - IReadOnlyList? Extensions = null); + IReadOnlyList? Extensions = null, + int? SettingsFormat = null); /// Names of that clients act on. public static class ServerCapabilities diff --git a/src/Chronos.Protocol/Jobs.cs b/src/Chronos.Protocol/Jobs.cs index ebd71a4d..362145cb 100644 --- a/src/Chronos.Protocol/Jobs.cs +++ b/src/Chronos.Protocol/Jobs.cs @@ -28,7 +28,11 @@ public sealed record CreateJobRequest(string Kind, IReadOnlyList Target, s /// POST /api/v1/nodes/register: a client offers its GPU encoders (BRIEF §14.7). × /// is the largest output of any of them, for encoders that announce no limit of their own. /// -public sealed record RegisterNodeRequest(string ClientName, IReadOnlyList Encoders, int MaxWidth, int MaxHeight); +/// +/// The highest project settings format the node renders (ProjectSettings.CurrentVersion); 1 from an older node, +/// which is then never given a job that needs more (). +/// +public sealed record RegisterNodeRequest(string ClientName, IReadOnlyList Encoders, int MaxWidth, int MaxHeight, int SettingsFormat = 1); /// /// One encoder of a render node. × is its largest output (0 = not announced: @@ -59,8 +63,13 @@ public sealed record JobPriorityRequest(string Priority); /// frames before the render. /// The project whose version is rendered (owner review 2, R8); recorded with the render. /// The project version rendered; recorded with the render. +/// +/// The settings format a program must read to render the job as asked (RenderRules.RequiredFormat: the settings' +/// format, at least 2 when the chosen proportions change a fixed preset's size); 1 in a job of an older server. A hint for +/// routing: a node recomputes it from the settings it claims. +/// public sealed record RenderJobParameters(string PresetName, string PresetJson, string Codec, int Width, int Height, bool UseProxies, string? SettingsJson, - Guid? ProjectId = null, Guid? ProjectVersionId = null); + Guid? ProjectId = null, Guid? ProjectVersionId = null, int RequiredSettingsFormat = 1); /// /// POST /api/v1/nodes/{id}/jobs/{jobId}/result: the finished output a node is about to upload in chunks. A diff --git a/src/Chronos.Ui/Icons/Icons.xaml b/src/Chronos.Ui/Icons/Icons.xaml index 2b3fa83c..6125ee43 100644 --- a/src/Chronos.Ui/Icons/Icons.xaml +++ b/src/Chronos.Ui/Icons/Icons.xaml @@ -39,6 +39,7 @@ + @@ -60,6 +61,7 @@ + @@ -75,6 +77,8 @@ + + @@ -85,6 +89,7 @@ + diff --git a/tests/Chronos.App.Tests/Editor/ProjectHistoryTests.cs b/tests/Chronos.App.Tests/Editor/ProjectHistoryTests.cs index f7e8505a..8c58dc81 100644 --- a/tests/Chronos.App.Tests/Editor/ProjectHistoryTests.cs +++ b/tests/Chronos.App.Tests/Editor/ProjectHistoryTests.cs @@ -117,7 +117,7 @@ public sealed class ProjectHistoryTests [Test] public void SettingsOfANewerChronosAdoptedDropTheStepsInsteadOfMergingThem() { - var newer = ProjectSettings.FromJson("""{ "version": 2, "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }""", allowNewer: true); + var newer = ProjectSettings.FromJson("""{ "version": 3, "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }""", allowNewer: true); // The workspace's merge throws as ProjectMerge does where both sides changed and one is a newer Chronos's. foreach (var merge in new Func?[] { null, (basis, ours, theirs) => ProjectMerge.MergeWithConflicts(basis, ours, theirs).Merged }) diff --git a/tests/Chronos.Core.Tests/Project/ProjectBundleTests.cs b/tests/Chronos.Core.Tests/Project/ProjectBundleTests.cs index a0d5fcf2..1e1adb0c 100644 --- a/tests/Chronos.Core.Tests/Project/ProjectBundleTests.cs +++ b/tests/Chronos.Core.Tests/Project/ProjectBundleTests.cs @@ -96,13 +96,13 @@ public sealed class ProjectBundleTests(TestContext context) { var workspace = new BundleWorkspace(Guid.CreateVersion7(), "Main", true, new BundleHome(BundleHome.ArchiveKind, SequenceId, ArchiveId), null, new BundleMedia(BundleMedia.Proxies, 0)); - var json = (Sample() with { Workspace = workspace }).ToJson().Replace("\"version\": 1", "\"version\": 2", StringComparison.Ordinal); + var json = (Sample() with { Workspace = workspace }).ToJson().Replace("\"version\": 1", "\"version\": 3", StringComparison.Ordinal); var bundle = ProjectBundle.Parse(json); Assert.True(bundle.IsReadOnly); Assert.True(bundle.Project.IsNewerFormat); Assert.Equal(0.8, bundle.Project.Exposure.DeflickerStrength.Resolve(1.0)); - var plain = Sample().ToJson().Replace("\"version\": 1", "\"version\": 2", StringComparison.Ordinal); + var plain = Sample().ToJson().Replace("\"version\": 1", "\"version\": 3", StringComparison.Ordinal); Assert.Throws(() => ProjectBundle.Parse(plain)); } diff --git a/tests/Chronos.Core.Tests/Project/ProjectContentTests.cs b/tests/Chronos.Core.Tests/Project/ProjectContentTests.cs index ef1de52d..40957e3b 100644 --- a/tests/Chronos.Core.Tests/Project/ProjectContentTests.cs +++ b/tests/Chronos.Core.Tests/Project/ProjectContentTests.cs @@ -131,7 +131,7 @@ public sealed class ProjectContentTests Assert.Equal(saved, ProjectContent.Rebind(saved, Frames(Photo(7)))); Assert.False(ProjectContent.SameChoices(saved, current, Frames(Photo(7)))); // A newer Chronos's settings are its own to rename. - var newer = """{ "version": 2, "pendingFrames": [ { "size": 1001, "capturedAt": "2026-09-28T18:00:10", "excluded": true } ] }"""; + var newer = """{ "version": 3, "pendingFrames": [ { "size": 1001, "capturedAt": "2026-09-28T18:00:10", "excluded": true } ] }"""; Assert.Equal(newer, ProjectContent.Rebind(newer, now)); } @@ -329,12 +329,12 @@ public sealed class ProjectContentTests [Test] public void SettingsOfANewerFormatAreReadOnlyAndKeptAsTheyAre() { - var newer = """{ "version": 2, "excludedFrames": [1], "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }"""; + var newer = """{ "version": 3, "excludedFrames": [1], "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }"""; Assert.Throws(() => ProjectSettings.FromJson(newer)); var read = ProjectSettings.FromJson(newer, allowNewer: true); Assert.True(read.IsNewerFormat); Assert.Equal(1.5, read.Exposure.ExposureOffsetEv); - Assert.Equal(2, ProjectContent.FormatOf(newer)); + Assert.Equal(3, ProjectContent.FormatOf(newer)); Assert.Equal(1, ProjectContent.FormatOf("""{ "exposure": {} }""")); // Its positions are a newer Chronos's to translate: only the text is made canonical. diff --git a/tests/Chronos.Core.Tests/Project/ProjectSettingsTests.cs b/tests/Chronos.Core.Tests/Project/ProjectSettingsTests.cs index 2fe17a24..e319ea55 100644 --- a/tests/Chronos.Core.Tests/Project/ProjectSettingsTests.cs +++ b/tests/Chronos.Core.Tests/Project/ProjectSettingsTests.cs @@ -77,7 +77,7 @@ public sealed class ProjectSettingsTests Assert.Equal("{date} {title} - {preset}", partial.Export.NameTemplate); Assert.SequenceEqual(new[] { 0.0, 1.0 }, partial.Timing.RemapCurve.Select(p => p.X)); Assert.Equal(9, partial.Stack.Length); - Assert.Equal(ProjectSettings.CurrentVersion, partial.Version); + Assert.Equal(ProjectSettings.BaseVersion, partial.Version); // An explicit null clears a nullable value; arrays are replaced, not merged. var cleared = ProjectSettings.FromJson("""{ "exposure": { "highlightKnee": null }, "timing": { "remapCurve": [ { "x": 0, "y": 0.5 } ] } }"""); @@ -470,4 +470,156 @@ public sealed class ProjectSettingsTests Assert.Equal(24, s.GopLength); Assert.Equal(10, s.BitDepth); } + + /// SHA-256 of the default project's canonical text, as format-1 builds write it: none of phase 4's members, version 1. + private const string DefaultProjectHash = "df0b0f50b113475ece3753a80df0be05cc281cdaa1fa08a73a438ea9161358e0"; + + [Test] + public void ProjectsWithoutTheNewMembersKeepTheirTextAndHash() + { + var defaults = new ProjectSettings().ToJson(); + Assert.Equal(DefaultProjectHash, ProjectContent.Hash(ProjectContent.Canonical(defaults))); + Assert.Equal(OldBuild.Write(new OldProject()), defaults); + Assert.Contains("\"version\": 1", defaults); + foreach (var member in new[] { "rotate", "mirror", "flip", "straighten", "\"look\"" }) + Assert.False(defaults.Contains(member, StringComparison.Ordinal), member); + + // A project written by a format-1 build reads and writes back the same, byte for byte. + var older = new ProjectSettings + { + Camera = new CameraSettings { Crop = [0.1, 0.2, 0.5, 0.6], Aspect = new Auto().WithManual("9:16"), Keyframes = [new CameraKey(3, 0.4, 0.5, 1.5, 2)] }, + Exposure = new ExposureSettings { ExposureOffsetEv = 0.3 }, + }.ToJson(); + Assert.Equal(older, ProjectContent.Canonical(older)); + Assert.Equal(older, OldBuild.Write(OldBuild.Read(older))); + Assert.Equal(ProjectSettings.BaseVersion, ProjectContent.FormatOf(older)); + } + + [Test] + public void TheNewMembersRoundTripAndRaiseTheFormatOnlyWhileUsed() + { + var plain = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.5 } }; + Assert.Equal(ProjectSettings.BaseVersion, plain.RequiredFormat); + var turned = plain with { Camera = plain.Camera with { Rotate = 90, Mirror = true, Flip = true, Straighten = -3.5 } }; + var looked = plain with { Look = new LookSettings { Filter = "sepia", Strength = 0.6 } }; + foreach (var settings in new[] { turned, looked, plain with { Camera = new CameraSettings { Straighten = 1 } }, plain with { Camera = new CameraSettings { Flip = true } } }) + { + Assert.Equal(2, settings.RequiredFormat); + var json = settings.ToJson(); + Assert.Contains("\"version\": 2", json); + var back = ProjectSettings.FromJson(json); + Assert.Equal(2, back.Version); + Assert.False(back.IsNewerFormat); + Assert.Equal(json, back.ToJson()); + } + var read = ProjectSettings.FromJson(turned.ToJson()); + Assert.Equal((90, true, true, -3.5), (read.Camera.Rotate, read.Camera.Mirror, read.Camera.Flip, read.Camera.Straighten)); + Assert.Equal((1, true), (read.Camera.Turns, read.Camera.IsOriented)); + var look = Assert.NotNull(ProjectSettings.FromJson(looked.ToJson()).Look); + Assert.Equal(("sepia", (double?)0.6), (look.Filter, look.Strength)); + + // Taken away again, the project is format 1 with the text it had before. + var undone = ProjectSettings.FromJson(turned.ToJson()) with { Camera = plain.Camera }; + Assert.Equal(ProjectSettings.BaseVersion, undone.RequiredFormat); + Assert.Equal(plain.ToJson(), undone.ToJson()); + Assert.Equal(plain.ToJson(), (ProjectSettings.FromJson(looked.ToJson()) with { Look = null }).ToJson()); + + // An identity look and a whole turn need nothing newer; an unknown look does (it is a newer Chronos's). + Assert.Equal(1, (plain with { Look = new LookSettings { Filter = "none" } }).RequiredFormat); + Assert.Equal(1, (plain with { Look = new LookSettings { Filter = "mono", Strength = 0 } }).RequiredFormat); + Assert.Equal(1, (plain with { Camera = new CameraSettings { Rotate = 360 } }).RequiredFormat); + Assert.Equal(2, (plain with { Look = new LookSettings { Filter = "film" } }).RequiredFormat); + Assert.Equal(3, new CameraSettings { Rotate = -90 }.Turns); + } + + [Test] + public void TheNewMembersComeAfterTheOldOnesSoAnOlderBuildWritesThemBackInPlace() + { + var settings = new ProjectSettings + { + Camera = new CameraSettings { Crop = [0.2, 0, 0.6, 1], Keyframes = [new CameraKey(1, 0.5, 0.5, 2, 0)], Rotate = 270, Straighten = 2.25 }, + HeroFrame = 4, + Look = new LookSettings { Filter = "warm" }, + }; + var canonical = ProjectContent.Canonical(settings.ToJson()); + + // A format-1 build keeps them as members it does not know, and writes them where they were. + var old = OldBuild.Read(canonical); + Assert.True(old.Camera.Extra!.ContainsKey("rotate") && old.Extra!.ContainsKey("look")); + Assert.Equal(canonical, OldBuild.Write(old)); + Assert.Equal(ProjectContent.Hash(canonical), ProjectContent.Hash(OldBuild.Write(old))); + var camera = System.Text.Json.Nodes.JsonNode.Parse(canonical)!["camera"]!.AsObject().Select(p => p.Key).ToList(); + Assert.SequenceEqual(["crop", "aspect", "offsetX", "offsetY", "keyframes", "rotate", "straighten"], camera); + } + + [Test] + public void ANewerFormatStaysReadOnlyAndKeepsItsNumber() + { + const string newer = """{ "version": 3, "camera": { "rotate": 90 }, "look": { "filter": "film", "grain": 0.2 } }"""; + Assert.Throws(() => ProjectSettings.FromJson(newer)); + var read = ProjectSettings.FromJson(newer, allowNewer: true); + Assert.True(read.IsNewerFormat); + Assert.Equal(3, read.WrittenFormat); + var canonical = ProjectContent.Canonical(newer); + Assert.Equal(3, ProjectContent.FormatOf(canonical)); + Assert.Contains("\"grain\": 0.2", canonical); + Assert.Equal(canonical, ProjectContent.Canonical(canonical)); + + // A format-2 project is this Chronos's own (written as the format it needs); text without a version is format 1. + Assert.False(ProjectSettings.FromJson("""{ "version": 2 }""").IsNewerFormat); + Assert.Equal(1, ProjectSettings.FromJson("""{ "version": 2 }""").WrittenFormat); + Assert.Equal(1, ProjectContent.FormatOf("""{ "camera": {} }""")); + Assert.Equal(1, ProjectContent.FormatOf(null)); + } + + /// + /// The settings as a format-1 build reads and writes them: its camera without phase 4's members and its project without + /// the look, with the same serialiser options. What it does not know lands in Extra. + /// + private static class OldBuild + { + public static OldProject Read(string json) => System.Text.Json.JsonSerializer.Deserialize(json, OldJson.Default.OldProject)!; + + public static string Write(OldProject project) => System.Text.Json.JsonSerializer.Serialize(project, OldJson.Default.OldProject); + } } + +/// A format-1 build's camera (before owner review 1, phase 4). +internal sealed record OldCamera +{ + public double[]? Crop { get; init; } + public Auto Aspect { get; init; } = new(); + public double OffsetX { get; init; } + public double OffsetY { get; init; } + public IReadOnlyList Keyframes { get; init; } = []; + + [System.Text.Json.Serialization.JsonExtensionData] + public Dictionary? Extra { get; set; } +} + +/// A format-1 build's project (before owner review 1, phase 4). +internal sealed record OldProject +{ + public int Version { get; init; } = 1; + public TimingSettings Timing { get; init; } = new(); + public ExposureSettings Exposure { get; init; } = new(); + public MotionSettings Motion { get; init; } = new(); + public OldCamera Camera { get; init; } = new(); + public StackSettings Stack { get; init; } = new(); + public ExportSettings Export { get; init; } = new(); + public IReadOnlyList ExcludedFrames { get; init; } = []; + public int? HeroFrame { get; init; } + public IReadOnlyList? PendingFrames { get; init; } + + [System.Text.Json.Serialization.JsonExtensionData] + public Dictionary? Extra { get; set; } +} + +[System.Text.Json.Serialization.JsonSourceGenerationOptions( + WriteIndented = true, + PropertyNamingPolicy = System.Text.Json.Serialization.JsonKnownNamingPolicy.CamelCase, + DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, + UseStringEnumConverter = true, + PropertyNameCaseInsensitive = true)] +[System.Text.Json.Serialization.JsonSerializable(typeof(OldProject))] +internal sealed partial class OldJson : System.Text.Json.Serialization.JsonSerializerContext; diff --git a/tests/Chronos.Core.Tests/Render/RenderRulesTests.cs b/tests/Chronos.Core.Tests/Render/RenderRulesTests.cs new file mode 100644 index 00000000..2332a98d --- /dev/null +++ b/tests/Chronos.Core.Tests/Render/RenderRulesTests.cs @@ -0,0 +1,30 @@ +using Chronos.Core.Export; +using Chronos.Core.Project; +using Chronos.Core.Render; +using Chronos.Testing; + +namespace Chronos.Core.Tests.Render; + +public sealed class RenderRulesTests +{ + [Test] + public void AMismatchedFixedPresetNeedsFormatTwo() + { + var project = new ProjectSettings { Camera = Camera("9:16") }; + Assert.Equal(2, RenderRules.RequiredFormat(project, Export("4k-h264"), 6000, 4000)); + // The same proportions as the preset, "source" or a free-size preset change nothing an older build would render. + Assert.Equal(1, RenderRules.RequiredFormat(project with { Camera = Camera("16:9") }, Export("4k-h264"), 6000, 4000)); + Assert.Equal(1, RenderRules.RequiredFormat(new ProjectSettings(), Export("4k-h264"), 6000, 4000)); + Assert.Equal(1, RenderRules.RequiredFormat(project, Export("png-sequence"), 6000, 4000)); + // The settings' own format counts too. + var turned = new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } }; + Assert.Equal(2, RenderRules.RequiredFormat(turned, Export("png-sequence"), 6000, 4000)); + var newer = ProjectSettings.FromJson("""{ "version": 3 }""", allowNewer: true); + Assert.Equal(3, RenderRules.RequiredFormat(newer, Export("4k-h264"), 6000, 4000)); + } + + private static CameraSettings Camera(string aspect) => new() { Aspect = new Auto().WithManual(aspect) }; + + private static ResolvedExport Export(string preset, ExportOverrides? overrides = null) => + ExportResolver.Resolve(new ExportSettings { Preset = new Auto().WithManual(preset), Overrides = overrides ?? new ExportOverrides() }); +} diff --git a/tests/Chronos.Core.Tests/Render/RenderSizeTests.cs b/tests/Chronos.Core.Tests/Render/RenderSizeTests.cs new file mode 100644 index 00000000..fba4a583 --- /dev/null +++ b/tests/Chronos.Core.Tests/Render/RenderSizeTests.cs @@ -0,0 +1,83 @@ +using Chronos.Core.Export; +using Chronos.Core.Project; +using Chronos.Core.Render; +using Chronos.Testing; + +namespace Chronos.Core.Tests.Render; + +public sealed class RenderSizeTests +{ + [Theory] + [Case("4k-h264", "9:16", 2160, 3840)] + [Case("4k-h264", "1:1", 2160, 2160)] + [Case("4k-h264", "4:5", 2160, 2700)] + [Case("4k-h264", "21:9", 3840, 1646)] + [Case("4k-h264", "16:9", 3840, 2160)] + [Case("1080p-h264", "9:16", 1080, 1920)] + [Case("vertical-1080x1920", "16:9", 1920, 1080)] + [Case("vertical-1080x1920", "9:16", 1080, 1920)] + public void TheChosenProportionsWinOverAFixedPreset(string preset, string aspect, int width, int height) => + Assert.Equal((width, height), RenderSize.Of(Camera(aspect), Export(preset), 6000, 4000)); + + [Test] + public void SourceKeepsThePresetsSize() + { + Assert.Equal((3840, 2160), RenderSize.Of(new CameraSettings(), Export("4k-h264"), 3000, 4000)); + Assert.Equal((1080, 1920), RenderSize.Of(Camera("source"), Export("vertical-1080x1920"), 6000, 4000)); + // An aspect that cannot be read renders as source. + Assert.Equal((3840, 2160), RenderSize.Of(Camera("wide"), Export("4k-h264"), 6000, 4000)); + // The Auto's advised value counts like a manual one. + var advised = new CameraSettings { Aspect = new Auto().WithAdvice("9:16", null) }; + Assert.Equal((2160, 3840), RenderSize.Of(advised, Export("4k-h264"), 6000, 4000)); + } + + [Test] + public void SizesAreEvenOnlyForCodecsThatNeedIt() + { + var png = Export("png-sequence", new ExportOverrides { Width = 1001, Height = 1001 }); + Assert.Equal((563, 1001), RenderSize.Of(Camera("9:16"), png, 6000, 4000)); + var h264 = Export("1080p-h264", new ExportOverrides { Width = 1001, Height = 1001 }); + Assert.Equal((562, 1000), RenderSize.Of(Camera("9:16"), h264, 6000, 4000)); + } + + [Test] + public void FreeSizePresetsAreUnchanged() + { + // No side given: the aspect-fitted crop of the view, capped by the decode size. + var png = Export("png-sequence"); + Assert.Equal((6000, 4000), RenderSize.Of(new CameraSettings(), png, 6000, 4000)); + Assert.Equal((2250, 4000), RenderSize.Of(Camera("9:16"), png, 6000, 4000)); + Assert.Equal((1500, 1000), RenderSize.Of(new CameraSettings(), png, 6000, 4000, maxWorkingLongEdge: 1500)); + Assert.Equal((3000, 2000), RenderSize.Of(new CameraSettings { Crop = [0.25, 0.25, 0.5, 0.5] }, png, 6000, 4000)); + // One side given: the other from the ratio. + Assert.Equal((1200, 800), RenderSize.Of(new CameraSettings(), Export("png-sequence", new ExportOverrides { Width = 1200 }), 6000, 4000)); + Assert.Equal((450, 800), RenderSize.Of(Camera("9:16"), Export("png-sequence", new ExportOverrides { Height = 800 }), 6000, 4000)); + } + + [Test] + public void AQuarterTurnTurnsTheSourceRatio() + { + var turned = new CameraSettings { Rotate = 90 }; + Assert.Equal((4000, 6000), RenderSize.Of(turned, Export("png-sequence"), 6000, 4000)); + Assert.Equal((4000, 6000), RenderSize.ViewSize(turned, 6000, 4000)); + Assert.Equal((6000, 4000), RenderSize.ViewSize(turned with { Rotate = 180 }, 6000, 4000)); + // A fixed preset with "source" keeps its own size whatever the turn. + Assert.Equal((3840, 2160), RenderSize.Of(turned, Export("4k-h264"), 6000, 4000)); + Assert.Approximately(2 / 3.0, RenderSize.Ratio(turned, Export("png-sequence"), 6000, 4000), 1e-12); + } + + [Test] + public void AdaptTurnsTheBoxToTheRatiosOrientation() + { + Assert.Equal((2160, 3840), RenderSize.Adapt(3840, 2160, 9 / 16.0)); + Assert.Equal((2160, 3840), RenderSize.Adapt(2160, 3840, 9 / 16.0)); + Assert.Equal((1920, 1080), RenderSize.Adapt(1080, 1920, 16 / 9.0)); + Assert.Equal((1080, 1080), RenderSize.Adapt(1080, 1920, 1)); + Assert.Throws(() => RenderSize.Adapt(1920, 1080, 0)); + } + + private static CameraSettings Camera(string aspect) => new() { Aspect = new Auto().WithManual(aspect) }; + + private static ResolvedExport Export(string preset, ExportOverrides? overrides = null) => + ExportResolver.Resolve(new ExportSettings { Preset = new Auto().WithManual(preset), Overrides = overrides ?? new ExportOverrides() }); +} diff --git a/tests/Chronos.Data.Tests/Projects/ProjectMergeTests.cs b/tests/Chronos.Data.Tests/Projects/ProjectMergeTests.cs index 025849d9..77052e40 100644 --- a/tests/Chronos.Data.Tests/Projects/ProjectMergeTests.cs +++ b/tests/Chronos.Data.Tests/Projects/ProjectMergeTests.cs @@ -21,6 +21,55 @@ public sealed class ProjectMergeTests private static PendingFrame Waiting(FramePhoto photo, bool excluded = false, bool hero = false) => new() { Sha256 = photo.Sha256, Size = photo.Size, CapturedAt = photo.CapturedAt, Excluded = excluded, Hero = hero }; + [Test] + public void ATurnOnOneSideAndALookOnTheOtherMergeIntoFormatTwo() + { + var basis = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.2 } }; + var ours = basis with { Camera = basis.Camera with { Rotate = 90, Straighten = 1.5 } }; + var theirs = basis with { Look = new LookSettings { Filter = "sepia", Strength = 0.6 } }; + + var result = ProjectMerge.MergeWithConflicts(basis, ours, theirs); + + Assert.False(result.HasConflicts); + Assert.Equal((90, 1.5), (result.Merged.Camera.Rotate, result.Merged.Camera.Straighten)); + Assert.Equal("sepia", result.Merged.Look?.Filter); + Assert.Equal(2, result.Merged.Version); + Assert.Contains("\"version\": 2", result.Merged.ToJson()); + + // One side takes the turn away while the other keeps the look: the format the members need, not the one taken. + var undone = ProjectMerge.MergeWithConflicts(result.Merged, result.Merged with { Camera = basis.Camera }, result.Merged with { Look = null }).Merged; + Assert.Equal(1, ProjectContent.FormatOf(undone.ToJson())); + Assert.Equal(basis.ToJson(), undone.ToJson()); + } + + [Test] + public void BothSidesCroppingGiveOneCropConflict() + { + var basis = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto().WithManual("9:16") } }; + var ours = basis with { Camera = basis.Camera with { Crop = [0.1, 0, 0.3, 0.9] } }; + var theirs = basis with { Camera = basis.Camera with { Crop = [0.5, 0.05, 0.2, 0.6], Mirror = true } }; + + var result = ProjectMerge.MergeWithConflicts(basis, ours, theirs); + + // The box is one value: never the x of one side and the width of the other. + Assert.SequenceEqual(["camera.crop"], result.Conflicts.Select(c => c.Path)); + Assert.SequenceEqual([0.1, 0, 0.3, 0.9], Assert.NotNull(result.Merged.Camera.Crop)); + Assert.True(result.Merged.Camera.Mirror); + Assert.SequenceEqual([0.5, 0.05, 0.2, 0.6], Assert.NotNull( + ProjectMerge.MergeWithConflicts(basis, ours, theirs, new HashSet { "camera.crop" }).Merged.Camera.Crop)); + } + + [Test] + public void AFormatThreeSideIsNeverMerged() + { + var basis = new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } }; + var newer = ProjectSettings.FromJson("""{ "version": 3, "camera": { "rotate": 180 }, "look": { "filter": "film" } }""", allowNewer: true); + var mine = basis with { Look = new LookSettings { Filter = "warm" } }; + Assert.Throws(() => ProjectMerge.MergeWithConflicts(basis, mine, newer)); + Assert.Throws(() => ProjectMerge.MergeWithConflicts(basis, newer, mine)); + Assert.Equal(3, ProjectMerge.MergeWithConflicts(basis, basis, newer).Merged.Version); + } + [Test] public void EntriesOfOnePhotoMergeAsOneWithThePositionsOfBoth() { @@ -69,7 +118,7 @@ public sealed class ProjectMergeTests public void SettingsOfANewerChronosAreNeverMergedWithThisOnes() { var basis = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.1 } }; - var newer = ProjectSettings.FromJson("""{ "version": 2, "exposure": { "exposureOffsetEv": 0.5 }, "grade": { "look": "film" } }""", allowNewer: true); + var newer = ProjectSettings.FromJson("""{ "version": 3, "exposure": { "exposureOffsetEv": 0.5 }, "grade": { "look": "film" } }""", allowNewer: true); var mine = basis with { Stack = new StackSettings { Mode = StackSetting.Median } }; // Both changed: refused, whichever side the newer one is, in a replay too. diff --git a/tests/Chronos.Data.Tests/Projects/ProjectRecoveryTests.cs b/tests/Chronos.Data.Tests/Projects/ProjectRecoveryTests.cs index 74acf18b..104a0f86 100644 --- a/tests/Chronos.Data.Tests/Projects/ProjectRecoveryTests.cs +++ b/tests/Chronos.Data.Tests/Projects/ProjectRecoveryTests.cs @@ -327,7 +327,7 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c var folder = fx.Paths.Sequence(sequence.Folder); // A newer Chronos on another PC sharing the archive pushes version 2 in its settings format, and mirrors it. - var settings = """{ "version": 2, "exposure": { "exposureOffsetEv": 0.5 }, "futureThing": true }"""; + var settings = """{ "version": 3, "exposure": { "exposureOffsetEv": 0.5 }, "futureThing": true }"""; var now = DateTimeOffset.UtcNow; var future = new ProjectVersion { @@ -339,7 +339,7 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c ClientName = "newer", SettingsJson = settings, ContentHash = ProjectContent.Hash(settings), - SettingsFormat = 2, + SettingsFormat = 3, FramesVersion = head.FramesVersion, CreatedAt = now, StoredAt = now, diff --git a/tests/Chronos.Data.Tests/Workspaces/WorkspaceMergeTests.cs b/tests/Chronos.Data.Tests/Workspaces/WorkspaceMergeTests.cs index 64b63a33..4ad731e3 100644 --- a/tests/Chronos.Data.Tests/Workspaces/WorkspaceMergeTests.cs +++ b/tests/Chronos.Data.Tests/Workspaces/WorkspaceMergeTests.cs @@ -332,7 +332,7 @@ public abstract class WorkspaceMergeTests(TestContext context) : DatabaseTest(co Assert.Equal(local.Id, sync.Unpushed(id).Single().Id); Assert.Equal(local.SettingsJson, sync.Unpushed(id).Single().SettingsJson); var working = (await sync.OpenAsync(id, fx.Ct)).Working; - Assert.Equal((ProjectSettings.CurrentVersion, 0.3), (working.Version, working.Exposure.ExposureOffsetEv)); + Assert.Equal((ProjectSettings.BaseVersion, 0.3), (working.Version, working.Exposure.ExposureOffsetEv)); Assert.SequenceEqual([1], working.ExcludedFrames); Assert.Equal(WorkspaceState.Conflict, (await sync.PullAsync(id, fx.Home, fx.Ct)).Status.State); diff --git a/tests/Chronos.Data.Tests/Workspaces/WorkspaceTests.cs b/tests/Chronos.Data.Tests/Workspaces/WorkspaceTests.cs index 9b43d418..559ab9af 100644 --- a/tests/Chronos.Data.Tests/Workspaces/WorkspaceTests.cs +++ b/tests/Chronos.Data.Tests/Workspaces/WorkspaceTests.cs @@ -455,7 +455,7 @@ public abstract class WorkspaceTests(TestContext context) : DatabaseTest(context var (_, sync) = fx.Workspace(); var project = await fx.CheckoutAsync(sync); var bundle = project.ReadBundle(); - File.WriteAllText(project.BundlePath, bundle.ToJson().Replace("\"version\": 1", "\"version\": 2", StringComparison.Ordinal)); + File.WriteAllText(project.BundlePath, bundle.ToJson().Replace("\"version\": 1", "\"version\": 3", StringComparison.Ordinal)); var session = await sync.OpenAsync(project.ProjectId, fx.Ct); Assert.True(session.IsReadOnly);