Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: address the capcodec review findings

Richie McIlroyf9ba899c2241
diff --git a/apps/media-server/capcodec-benchmarks.md b/apps/media-server/capcodec-benchmarks.md
index f412d8255..1fb29651a 100644
--- a/apps/media-server/capcodec-benchmarks.md
+++ b/apps/media-server/capcodec-benchmarks.md
@@ -2,7 +2,7 @@
Measurements from the capcodec bench harness for the binary `CAP_MEDIA_VIDEO_ENCODER=capcodec` runs. This repository's CI does not regenerate them. A speed ratio above 1 means capcodec is faster. A BD-rate below 0 means capcodec uses fewer bits at the same quality.
-The 12-clip speed table is main `00fecf7` (read-ahead, CABAC, intra minIndex), retimed with other processes stopped. `--bframes 0` matches that encoder. Concurrent B-frames are the default after that measurement. Screen clips stay almost entirely P frames, so those speed rows still describe the default. full_motion was retimed with concurrent B-frames: 4-thread wall is 1.35-1.40x medium and 1.44-1.50x live (the same sessions measured the previous encoder at 1.09-1.10x and 1.19-1.21x). The other 11 clips were not retimed. full_motion quality below is the pre-concurrent-B bitstream.
+The 12-clip speed table is main `00fecf7` (read-ahead, CABAC, intra minIndex), retimed with other processes stopped. The 4-thread column ran capcodec with `--threads 4` and x264 with `-threads 0` (automatic). The 1-thread column set both to 1 thread. `--bframes 0` matches that encoder. Concurrent B-frames are the default after that measurement. Screen clips stay almost entirely P frames, so those speed rows still describe the default. full_motion was retimed with concurrent B-frames: 4-thread wall is 1.35-1.40x medium and 1.44-1.50x live (the same sessions measured the previous encoder at 1.09-1.10x and 1.19-1.21x). The other 11 clips were not retimed. full_motion quality below is the pre-concurrent-B bitstream.
`rd-next` (`d0cce5e`) and SSIM round 3 (`b72e995`) are not in the binary this flag runs. The media server's `ultrafast` preset maps to capcodec `fast`. Job CRF and preset apply unless `CAPCODEC_CRF` or `CAPCODEC_PRESET` is set.
diff --git a/apps/media-server/capcodec.md b/apps/media-server/capcodec.md
index ec5a4b361..0a52ec848 100644
--- a/apps/media-server/capcodec.md
+++ b/apps/media-server/capcodec.md
@@ -11,4 +11,6 @@ To encode with capcodec:
Optional overrides: `CAPCODEC_CRF` (0–51), `CAPCODEC_PRESET` (`live`, `fast`, `medium`, `slow`), `CAPCODEC_KEYINT`, and `CAPCODEC_NOISE`. Without those, the job's CRF and preset are used. `ultrafast` maps to `fast`.
+The server writes a fragmented MP4 (`.fmp4`) so capcodec flushes each GOP, then ffmpeg remuxes audio and faststart. The decode filter converts frames to limited-range BT.709, matching the labels the encoder writes.
+
Benchmark tables against x264 veryfast are in `capcodec-benchmarks.md`. The encoder source is `capcodec/` at the repository root.
diff --git a/apps/media-server/src/__tests__/lib/capcodec-encoder.test.ts b/apps/media-server/src/__tests__/lib/capcodec-encoder.test.ts
index 890913d47..174c18837 100644
--- a/apps/media-server/src/__tests__/lib/capcodec-encoder.test.ts
+++ b/apps/media-server/src/__tests__/lib/capcodec-encoder.test.ts
@@ -134,6 +134,9 @@ describe("capcodec encoder integration", () => {
"30/1",
);
expect(decode.slice(-4)).toEqual(["yuv420p", "-progress", "pipe:2", "-"]);
+ expect(decode).toContain(
+ "scale=1920:1080:flags=bicubic:in_color_matrix=auto:out_color_matrix=bt709:in_range=auto:out_range=tv,format=yuv420p",
+ );
expect(decode).toContain("rawvideo");
const encode = buildCapcodecEncodeArgs(
{
diff --git a/apps/media-server/src/lib/capcodec-encoder.ts b/apps/media-server/src/lib/capcodec-encoder.ts
index 45892ce20..652c3c487 100644
--- a/apps/media-server/src/lib/capcodec-encoder.ts
+++ b/apps/media-server/src/lib/capcodec-encoder.ts
@@ -192,7 +192,7 @@ export function buildCapcodecDecodeArgs(
"-map",
"0:v:0",
"-vf",
- `scale=${width}:${height}:flags=bicubic,format=yuv420p`,
+ `scale=${width}:${height}:flags=bicubic:in_color_matrix=auto:out_color_matrix=bt709:in_range=auto:out_range=tv,format=yuv420p`,
"-fps_mode",
"cfr",
"-r",
diff --git a/apps/media-server/src/lib/media-video.ts b/apps/media-server/src/lib/media-video.ts
index 1e03bae0d..481589793 100644
--- a/apps/media-server/src/lib/media-video.ts
+++ b/apps/media-server/src/lib/media-video.ts
@@ -1704,7 +1704,7 @@ async function processVideoWithCapcodec(
onProgress?: ProgressCallback,
abortSignal?: AbortSignal,
): Promise<void> {
- const videoOnly = await createTempFile(".mp4");
+ const videoOnly = await createTempFile(".fmp4");
const controller = new AbortController();
const forwardAbort = () => controller.abort();
abortSignal?.addEventListener("abort", forwardAbort, { once: true });
diff --git a/capcodec/bench/bench.py b/capcodec/bench/bench.py
index 7c828b169..c64eb271f 100644
--- a/capcodec/bench/bench.py
+++ b/capcodec/bench/bench.py
@@ -18,9 +18,11 @@ HISTORY = BENCH / "history.jsonl"
def committed_best() -> dict | None:
- r = subprocess.run(["git", "-C", str(ROOT), "show", "HEAD:bench/best.json"], capture_output=True, text=True)
- if r.returncode == 0 and r.stdout.strip():
- return json.loads(r.stdout)
+ # A standalone checkout stores the file at bench/best.json. Inside Cap it is capcodec/bench/best.json.
+ for spec in ("HEAD:bench/best.json", "HEAD:capcodec/bench/best.json"):
+ r = subprocess.run(["git", "-C", str(ROOT), "show", spec], capture_output=True, text=True)
+ if r.returncode == 0 and r.stdout.strip():
+ return json.loads(r.stdout)
if BEST.exists():
return json.loads(BEST.read_text())
return None
diff --git a/capcodec/bench/corpus/pages/common/board.js b/capcodec/bench/corpus/pages/common/board.js
index 297bbf4b6..02c3f3fd5 100644
--- a/capcodec/bench/corpus/pages/common/board.js
+++ b/capcodec/bench/corpus/pages/common/board.js
@@ -1,49 +1,49 @@
(() => {
const D = window.BOARD;
const P = {
- inbox: '<path d="M3 13l3-8h12l3 8v6H3z"/><path d="M3 13h5l1 3h6l1-3h5"/>',
- user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c1-4 4-6 8-6s7 2 8 6"/>',
- review: '<circle cx="12" cy="12" r="3"/><path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"/>',
- pulse: '<path d="M3 12h4l3-7 4 14 3-7h4"/>',
- box: '<path d="M4 7l8-4 8 4v10l-8 4-8-4z"/><path d="M4 7l8 4 8-4M12 11v10"/>',
- layers: '<path d="M12 3l9 5-9 5-9-5z"/><path d="M3 13l9 5 9-5"/>',
- target: '<circle cx="12" cy="12" r="8"/><circle cx="12" cy="12" r="4"/>',
- users: '<circle cx="9" cy="8" r="3.5"/><path d="M2.5 20c.8-3.5 3.3-5.5 6.5-5.5s5.7 2 6.5 5.5"/><path d="M16 4.5a3.5 3.5 0 0 1 0 7M18.5 14.5c1.6.8 2.6 2.7 3 5.5"/>',
- issue: '<rect x="4" y="4" width="16" height="16" rx="4"/><path d="M9 12l2 2 4-4"/>',
- cycle: '<path d="M20 12a8 8 0 1 1-3-6.2"/><path d="M20 4v5h-5"/>',
- search: '<circle cx="11" cy="11" r="6.5"/><path d="M16 16l4.5 4.5"/>',
- edit: '<path d="M4 20h4L19 9l-4-4L4 16z"/>',
- star: '<path d="M12 4l2.5 5.2 5.7.8-4.1 4 1 5.6-5.1-2.7-5.1 2.7 1-5.6-4.1-4 5.7-.8z"/>',
- chev: '<path d="M9 6l6 6-6 6"/>',
- down: '<path d="M6 9l6 6 6-6"/>',
- board: '<rect x="4" y="4" width="5" height="16" rx="1.5"/><rect x="10.5" y="4" width="5" height="11" rx="1.5"/><rect x="17" y="4" width="3" height="7" rx="1"/>',
- list: '<path d="M8 6h12M8 12h12M8 18h12M4 6h.5M4 12h.5M4 18h.5"/>',
- timeline: '<path d="M4 6h9M8 12h12M6 18h8"/>',
- cal: '<rect x="4" y="5" width="16" height="15" rx="2"/><path d="M4 10h16M9 3v4M15 3v4"/>',
- filter: '<path d="M4 6h16M7 12h10M10 18h4"/>',
- display: '<path d="M4 7h10M18 7h2M4 17h4M12 17h8"/><circle cx="16" cy="7" r="2"/><circle cx="10" cy="17" r="2"/>',
- plus: '<path d="M12 5v14M5 12h14"/>',
- more: '<circle cx="6" cy="12" r="1.2"/><circle cx="12" cy="12" r="1.2"/><circle cx="18" cy="12" r="1.2"/>',
- comment: '<path d="M5 5h14v10H9l-4 4z"/>',
- subtask: '<path d="M6 4v10a3 3 0 0 0 3 3h9"/><path d="M15 14l3 3-3 3"/>',
- date: '<rect x="4" y="5" width="16" height="15" rx="2"/><path d="M4 10h16"/>',
- link: '<path d="M10 14a4 4 0 0 0 6 0l3-3a4 4 0 0 0-6-6l-1 1M14 10a4 4 0 0 0-6 0l-3 3a4 4 0 0 0 6 6l1-1"/>',
- close: '<path d="M6 6l12 12M18 6L6 18"/>',
- share: '<path d="M12 4v11M8 8l4-4 4 4M5 14v5h14v-5"/>',
- help: '<circle cx="12" cy="12" r="8"/><path d="M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.7.3-1 .9-1 1.7M12 16.5v.5"/>',
- bell: '<path d="M6 16V11a6 6 0 0 1 12 0v5l2 2H4z"/><path d="M10 20a2 2 0 0 0 4 0"/>',
- trash: '<path d="M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13"/>',
- copy: '<rect x="8" y="8" width="12" height="12" rx="2"/><path d="M16 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3"/>',
- archive: '<rect x="3" y="4" width="18" height="5" rx="1"/><path d="M5 9v10h14V9M10 13h4"/>',
+ inbox: "<path d=\"M3 13l3-8h12l3 8v6H3z\"/><path d=\"M3 13h5l1 3h6l1-3h5\"/>",
+ user: "<circle cx=\"12\" cy=\"8\" r=\"4\"/><path d=\"M4 21c1-4 4-6 8-6s7 2 8 6\"/>",
+ review: "<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z\"/>",
+ pulse: "<path d=\"M3 12h4l3-7 4 14 3-7h4\"/>",
+ box: "<path d=\"M4 7l8-4 8 4v10l-8 4-8-4z\"/><path d=\"M4 7l8 4 8-4M12 11v10\"/>",
+ layers: "<path d=\"M12 3l9 5-9 5-9-5z\"/><path d=\"M3 13l9 5 9-5\"/>",
+ target: "<circle cx=\"12\" cy=\"12\" r=\"8\"/><circle cx=\"12\" cy=\"12\" r=\"4\"/>",
+ users: "<circle cx=\"9\" cy=\"8\" r=\"3.5\"/><path d=\"M2.5 20c.8-3.5 3.3-5.5 6.5-5.5s5.7 2 6.5 5.5\"/><path d=\"M16 4.5a3.5 3.5 0 0 1 0 7M18.5 14.5c1.6.8 2.6 2.7 3 5.5\"/>",
+ issue: "<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"4\"/><path d=\"M9 12l2 2 4-4\"/>",
+ cycle: "<path d=\"M20 12a8 8 0 1 1-3-6.2\"/><path d=\"M20 4v5h-5\"/>",
+ search: "<circle cx=\"11\" cy=\"11\" r=\"6.5\"/><path d=\"M16 16l4.5 4.5\"/>",
+ edit: "<path d=\"M4 20h4L19 9l-4-4L4 16z\"/>",
+ star: "<path d=\"M12 4l2.5 5.2 5.7.8-4.1 4 1 5.6-5.1-2.7-5.1 2.7 1-5.6-4.1-4 5.7-.8z\"/>",
+ chev: "<path d=\"M9 6l6 6-6 6\"/>",
+ down: "<path d=\"M6 9l6 6 6-6\"/>",
+ board: "<rect x=\"4\" y=\"4\" width=\"5\" height=\"16\" rx=\"1.5\"/><rect x=\"10.5\" y=\"4\" width=\"5\" height=\"11\" rx=\"1.5\"/><rect x=\"17\" y=\"4\" width=\"3\" height=\"7\" rx=\"1\"/>",
+ list: "<path d=\"M8 6h12M8 12h12M8 18h12M4 6h.5M4 12h.5M4 18h.5\"/>",
+ timeline: "<path d=\"M4 6h9M8 12h12M6 18h8\"/>",
+ cal: "<rect x=\"4\" y=\"5\" width=\"16\" height=\"15\" rx=\"2\"/><path d=\"M4 10h16M9 3v4M15 3v4\"/>",
+ filter: "<path d=\"M4 6h16M7 12h10M10 18h4\"/>",
+ display: "<path d=\"M4 7h10M18 7h2M4 17h4M12 17h8\"/><circle cx=\"16\" cy=\"7\" r=\"2\"/><circle cx=\"10\" cy=\"17\" r=\"2\"/>",
+ plus: "<path d=\"M12 5v14M5 12h14\"/>",
+ more: "<circle cx=\"6\" cy=\"12\" r=\"1.2\"/><circle cx=\"12\" cy=\"12\" r=\"1.2\"/><circle cx=\"18\" cy=\"12\" r=\"1.2\"/>",
+ comment: "<path d=\"M5 5h14v10H9l-4 4z\"/>",
+ subtask: "<path d=\"M6 4v10a3 3 0 0 0 3 3h9\"/><path d=\"M15 14l3 3-3 3\"/>",
+ date: "<rect x=\"4\" y=\"5\" width=\"16\" height=\"15\" rx=\"2\"/><path d=\"M4 10h16\"/>",
+ link: "<path d=\"M10 14a4 4 0 0 0 6 0l3-3a4 4 0 0 0-6-6l-1 1M14 10a4 4 0 0 0-6 0l-3 3a4 4 0 0 0 6 6l1-1\"/>",
+ close: "<path d=\"M6 6l12 12M18 6L6 18\"/>",
+ share: "<path d=\"M12 4v11M8 8l4-4 4 4M5 14v5h14v-5\"/>",
+ help: "<circle cx=\"12\" cy=\"12\" r=\"8\"/><path d=\"M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.7.3-1 .9-1 1.7M12 16.5v.5\"/>",
+ bell: "<path d=\"M6 16V11a6 6 0 0 1 12 0v5l2 2H4z\"/><path d=\"M10 20a2 2 0 0 0 4 0\"/>",
+ trash: "<path d=\"M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13\"/>",
+ copy: "<rect x=\"8\" y=\"8\" width=\"12\" height=\"12\" rx=\"2\"/><path d=\"M16 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3\"/>",
+ archive: "<rect x=\"3\" y=\"4\" width=\"18\" height=\"5\" rx=\"1\"/><path d=\"M5 9v10h14V9M10 13h4\"/>",
};
const ic = (n) => `<svg class="i" viewBox="0 0 24 24">${P[n] || ""}</svg>`;
const STATUS = {
- backlog: '<svg class="i" viewBox="0 0 24 24" style="color:#9a9eab"><circle cx="12" cy="12" r="7.5" stroke-dasharray="3 2.6"/></svg>',
- todo: '<svg class="i" viewBox="0 0 24 24" style="color:#9a9eab"><circle cx="12" cy="12" r="7.5"/></svg>',
- progress: '<svg class="i" viewBox="0 0 24 24" style="color:#eab308"><circle cx="12" cy="12" r="7.5"/><path d="M12 7.5a4.5 4.5 0 0 1 0 9z" fill="#eab308" stroke="none"/></svg>',
- review: '<svg class="i" viewBox="0 0 24 24" style="color:#22c55e"><circle cx="12" cy="12" r="7.5"/><path d="M12 7.5a4.5 4.5 0 1 1-4.5 4.5H12z" fill="#22c55e" stroke="none"/></svg>',
- done: '<svg class="i" viewBox="0 0 24 24" style="color:#6366f1"><circle cx="12" cy="12" r="8" fill="#6366f1" stroke="none"/><path d="M8.5 12.2l2.4 2.4 4.6-4.8" stroke="#fff"/></svg>',
- canceled: '<svg class="i" viewBox="0 0 24 24" style="color:#9a9eab"><circle cx="12" cy="12" r="8" fill="#b4b7c0" stroke="none"/><path d="M9.5 9.5l5 5M14.5 9.5l-5 5" stroke="#fff"/></svg>',
+ backlog: "<svg class=\"i\" viewBox=\"0 0 24 24\" style=\"color:#9a9eab\"><circle cx=\"12\" cy=\"12\" r=\"7.5\" stroke-dasharray=\"3 2.6\"/></svg>",
+ todo: "<svg class=\"i\" viewBox=\"0 0 24 24\" style=\"color:#9a9eab\"><circle cx=\"12\" cy=\"12\" r=\"7.5\"/></svg>",
+ progress: "<svg class=\"i\" viewBox=\"0 0 24 24\" style=\"color:#eab308\"><circle cx=\"12\" cy=\"12\" r=\"7.5\"/><path d=\"M12 7.5a4.5 4.5 0 0 1 0 9z\" fill=\"#eab308\" stroke=\"none\"/></svg>",
+ review: "<svg class=\"i\" viewBox=\"0 0 24 24\" style=\"color:#22c55e\"><circle cx=\"12\" cy=\"12\" r=\"7.5\"/><path d=\"M12 7.5a4.5 4.5 0 1 1-4.5 4.5H12z\" fill=\"#22c55e\" stroke=\"none\"/></svg>",
+ done: "<svg class=\"i\" viewBox=\"0 0 24 24\" style=\"color:#6366f1\"><circle cx=\"12\" cy=\"12\" r=\"8\" fill=\"#6366f1\" stroke=\"none\"/><path d=\"M8.5 12.2l2.4 2.4 4.6-4.8\" stroke=\"#fff\"/></svg>",
+ canceled: "<svg class=\"i\" viewBox=\"0 0 24 24\" style=\"color:#9a9eab\"><circle cx=\"12\" cy=\"12\" r=\"8\" fill=\"#b4b7c0\" stroke=\"none\"/><path d=\"M9.5 9.5l5 5M14.5 9.5l-5 5\" stroke=\"#fff\"/></svg>",
};
const av = (k, size) => {
if (!k) return `<span class="av" style="background:#fff;border:1.5px dashed #b4b7c0;color:#9a9eab${size ? `;width:${size}px;height:${size}px` : ""}"></span>`;
@@ -51,8 +51,8 @@
return `<span class="av" style="background:${c}${size ? `;width:${size}px;height:${size}px` : ""}">${k}</span>`;
};
const prio = (p) => {
- if (p === 4) return '<span class="prio urgent">!</span>';
- if (p === 0) return '<span class="prio"><i style="height:2px"></i><i style="height:2px"></i><i style="height:2px"></i></span>';
+ if (p === 4) return "<span class=\"prio urgent\">!</span>";
+ if (p === 0) return "<span class=\"prio\"><i style=\"height:2px\"></i><i style=\"height:2px\"></i><i style=\"height:2px\"></i></span>";
return `<span class="prio"><i class="on" style="height:5px"></i><i class="${p >= 2 ? "on" : ""}" style="height:8px"></i><i class="${p >= 3 ? "on" : ""}" style="height:11px"></i></span>`;
};
const PRIO_NAMES = ["No priority", "Low", "Medium", "High", "Urgent"];
diff --git a/capcodec/bench/corpus/pages/common/dashboard.js b/capcodec/bench/corpus/pages/common/dashboard.js
index e4e6b7294..cf8c84a43 100644
--- a/capcodec/bench/corpus/pages/common/dashboard.js
+++ b/capcodec/bench/corpus/pages/common/dashboard.js
@@ -180,7 +180,7 @@
const pw = w - left - right;
const ph = h - top - bottom;
ctx.clearRect(0, 0, w, h);
- ctx.font = '11px "Noto Sans", "Liberation Sans", sans-serif';
+ ctx.font = "11px \"Noto Sans\", \"Liberation Sans\", sans-serif";
ctx.textBaseline = "middle";
const yTicks = 5;
for (let i = 0; i <= yTicks; i++) {
diff --git a/capcodec/bench/corpus/pages/common/editor.js b/capcodec/bench/corpus/pages/common/editor.js
index a46ccbb95..b0b33d547 100644
--- a/capcodec/bench/corpus/pages/common/editor.js
+++ b/capcodec/bench/corpus/pages/common/editor.js
@@ -140,7 +140,7 @@
continue;
}
}
- const sm = (lang === "py" ? /^[rRbBuUfF]{0,2}("|')/ : /^("|')/).exec(rest);
+ const sm = (lang === "py" ? /^[rRbBuUfF]{0,2}("|")/ : /^(\"|")/).exec(rest);
if (sm) {
const q = sm[1];
let j = i + sm[0].length;
@@ -290,7 +290,7 @@
let guides = "";
let k = 0;
while (k + 4 <= take) {
- guides += '<span class="ig"> </span>';
+ guides += "<span class=\"ig\"> </span>";
k += 4;
}
if (k < take) guides += " ".repeat(take - k);
@@ -333,7 +333,7 @@
insertRow(at) {
const d = document.createElement("div");
d.className = "ce-row";
- d.innerHTML = '<span class="ln"></span><span class="code"> </span>';
+ d.innerHTML = "<span class=\"ln\"></span><span class=\"code\"> </span>";
const ref = this.rowEls[at] || null;
this.rowsEl.insertBefore(d, ref);
this.rowEls.splice(at, 0, d);
@@ -474,7 +474,7 @@
if (col <= lead && col % 4 === 0) n = 4;
else if (col <= lead) n = col % 4;
const pair = text[col - 1] + (text[col] || "");
- if (["()", "[]", '""', "''"].includes(pair)) {
+ if (["()", "[]", "\"\"", "''"].includes(pair)) {
this.lines[line] = text.slice(0, col - 1) + text.slice(col + 1);
} else {
this.lines[line] = text.slice(0, col - n) + text.slice(col);
@@ -549,14 +549,14 @@
const text = this.lines[line];
const next = text[col] || "";
const closers = { "(": ")", "[": "]" };
- if ((ch === ")" || ch === "]" || ch === '"' || ch === "'") && next === ch) {
+ if ((ch === ")" || ch === "]" || ch === "\"" || ch === "'") && next === ch) {
this.caret.col++;
this.updateSuggest();
return;
}
let ins = ch;
if (closers[ch] && (!next || /[\s)\],:]/.test(next))) ins = ch + closers[ch];
- else if ((ch === '"' || ch === "'") && !/\w/.test(text[col - 1] || "") && text[col - 1] !== ch && (!next || /[\s)\],:]/.test(next))) ins = ch + ch;
+ else if ((ch === "\"" || ch === "'") && !/\w/.test(text[col - 1] || "") && text[col - 1] !== ch && (!next || /[\s)\],:]/.test(next))) ins = ch + ch;
let newText = text.slice(0, col) + ins + text.slice(col);
let newCol = col + 1;
if (this.lang === "c" && ch === "}" && /^ +$/.test(text.slice(0, col)) && col >= 4) {
diff --git a/capcodec/bench/corpus/pages/common/slides.js b/capcodec/bench/corpus/pages/common/slides.js
index 4e1d80af4..b5d660f96 100644
--- a/capcodec/bench/corpus/pages/common/slides.js
+++ b/capcodec/bench/corpus/pages/common/slides.js
@@ -81,7 +81,7 @@
["720p and below", 10, "#f59e0b"],
];
let a0 = -Math.PI / 2;
- let s = '<svg width="620" height="620" viewBox="-310 -310 620 620">';
+ let s = "<svg width=\"620\" height=\"620\" viewBox=\"-310 -310 620 620\">";
for (const [, pct, c] of parts) {
const a1 = a0 + (pct / 100) * Math.PI * 2;
const large = a1 - a0 > Math.PI ? 1 : 0;
@@ -90,7 +90,7 @@
s += `<path d="M${Math.cos(a0) * r} ${Math.sin(a0) * r} A${r} ${r} 0 ${large} 1 ${Math.cos(a1) * r} ${Math.sin(a1) * r} L${Math.cos(a1) * ri} ${Math.sin(a1) * ri} A${ri} ${ri} 0 ${large} 0 ${Math.cos(a0) * ri} ${Math.sin(a0) * ri}Z" fill="${c}"/>`;
a0 = a1;
}
- s += '<text x="0" y="-6" text-anchor="middle" font-family="Noto Sans" font-size="76" font-weight="800" fill="#1d2433">1.9M</text><text x="0" y="46" text-anchor="middle" font-family="Noto Sans" font-size="28" fill="#6b7280">recordings in Q3</text></svg>';
+ s += "<text x=\"0\" y=\"-6\" text-anchor=\"middle\" font-family=\"Noto Sans\" font-size=\"76\" font-weight=\"800\" fill=\"#1d2433\">1.9M</text><text x=\"0\" y=\"46\" text-anchor=\"middle\" font-family=\"Noto Sans\" font-size=\"28\" fill=\"#6b7280\">recordings in Q3</text></svg>";
const legend = parts
.map(([n, p, c]) => `<div style="display:flex;align-items:center;gap:22px;font-size:34px;margin-bottom:30px"><span style="width:30px;height:30px;border-radius:8px;background:${c}"></span><span style="flex:1">${n}</span><b>${p}%</b></div>`)
.join("");
diff --git a/capcodec/bench/corpus/pages/common/wiki.js b/capcodec/bench/corpus/pages/common/wiki.js
index ba1d668c7..cdf6d2e01 100644
--- a/capcodec/bench/corpus/pages/common/wiki.js
+++ b/capcodec/bench/corpus/pages/common/wiki.js
@@ -89,7 +89,7 @@ ${Array.from({ length: 5 }, (_, r) => {
const data = [0.12, 0.31, 0.55, 0.9, 1.15, 0.72, 1.05, 1.42, 1.9, 2.35, 2.62, 2.1, 1.35, 0.6, 0.22, 0.08, 0.04, 0.02, 0.01];
const years = [1900, 1905, 1910, 1915, 1920, 1925, 1930, 1935, 1940, 1945, 1950, 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990];
const series = [0.12, 0.3, 0.52, 0.85, 1.1, 0.95, 0.8, 0.98, 1.3, 1.6, 2.1, 2.55, 2.75, 2.6, 2.2, 1.6, 0.9, 0.35, 0.12];
- let s = '<rect width="330" height="236" fill="#fff"/>';
+ let s = "<rect width=\"330\" height=\"236\" fill=\"#fff\"/>";
for (let i = 0; i <= 6; i++) {
const y = 196 - i * 28;
s += `<line x1="40" x2="320" y1="${y}" y2="${y}" stroke="#e5e5e5"/><text x="34" y="${y + 4}" font-size="10" text-anchor="end" fill="#444" font-family="Noto Sans">${(i * 0.5).toFixed(1)}</text>`;
@@ -101,10 +101,10 @@ ${Array.from({ length: 5 }, (_, r) => {
if (i % 3 === 0) s += `<text x="${x + 5}" y="210" font-size="9.5" text-anchor="middle" fill="#444" font-family="Noto Sans">${years[i]}</text>`;
});
s += `<polyline fill="none" stroke="#d9534f" stroke-width="2" points="${data.map((v, i) => `${51 + i * 14.4},${196 - v * 56}`).join(" ")}"/>`;
- s += '<line x1="40" x2="320" y1="196" y2="196" stroke="#333"/><line x1="40" x2="40" y1="20" y2="196" stroke="#333"/>';
- s += '<rect x="196" y="16" width="10" height="10" fill="#5b8ccf"/><text x="210" y="25" font-size="10" fill="#222" font-family="Noto Sans">All typewriters</text>';
- s += '<line x1="196" x2="206" y1="38" y2="38" stroke="#d9534f" stroke-width="2"/><text x="210" y="41" font-size="10" fill="#222" font-family="Noto Sans">Portable models</text>';
- s += '<text x="180" y="230" font-size="10" text-anchor="middle" fill="#222" font-family="Noto Sans">Year</text>';
+ s += "<line x1=\"40\" x2=\"320\" y1=\"196\" y2=\"196\" stroke=\"#333\"/><line x1=\"40\" x2=\"40\" y1=\"20\" y2=\"196\" stroke=\"#333\"/>";
+ s += "<rect x=\"196\" y=\"16\" width=\"10\" height=\"10\" fill=\"#5b8ccf\"/><text x=\"210\" y=\"25\" font-size=\"10\" fill=\"#222\" font-family=\"Noto Sans\">All typewriters</text>";
+ s += "<line x1=\"196\" x2=\"206\" y1=\"38\" y2=\"38\" stroke=\"#d9534f\" stroke-width=\"2\"/><text x=\"210\" y=\"41\" font-size=\"10\" fill=\"#222\" font-family=\"Noto Sans\">Portable models</text>";
+ s += "<text x=\"180\" y=\"230\" font-size=\"10\" text-anchor=\"middle\" fill=\"#222\" font-family=\"Noto Sans\">Year</text>";
return s;
})(),
},
@@ -140,7 +140,7 @@ ${[
cap: "The QWERTY layout as used on most English-language typewriters",
svg: (() => {
const rows = ["1234567890-", "QWERTYUIOP", "ASDFGHJKL;", "ZXCVBNM,./"];
- let s = '<rect width="330" height="128" fill="#f4f4f4"/>';
+ let s = "<rect width=\"330\" height=\"128\" fill=\"#f4f4f4\"/>";
rows.forEach((r, ri) => {
[...r].forEach((ch, ci) => {
const x = 10 + ri * 9 + ci * 27;
@@ -148,7 +148,7 @@ ${[
s += `<rect x="${x}" y="${y}" width="24" height="24" rx="4" fill="#fff" stroke="#888"/><text x="${x + 12}" y="${y + 16.5}" text-anchor="middle" font-family="DejaVu Sans Mono" font-size="12" fill="#222">${ch}</text>`;
});
});
- s += '<rect x="80" y="116" width="170" height="10" rx="3" fill="#fff" stroke="#888"/>';
+ s += "<rect x=\"80\" y=\"116\" width=\"170\" height=\"10\" rx=\"3\" fill=\"#fff\" stroke=\"#888\"/>";
return s;
})(),
},
@@ -200,9 +200,9 @@ ${[
["<i>The Writing Machine</i>", "London: George Allen &amp; Unwin"],
["<i>Antique Typewriters and Office Collectibles</i>", "Paducah: Collector Books"],
["<i>Machine Writing and Typesetting</i>", "Salem, NH: GAMA"],
- ['"A historical study of typewriters and typing methods"', "<i>Journal of Information Processing</i>"],
- ['"Clio and the Economics of QWERTY"', "<i>American Economic Review</i>"],
- ['"The Fable of the Keys"', "<i>Journal of Law and Economics</i>"],
+ ["\"A historical study of typewriters and typing methods\"", "<i>Journal of Information Processing</i>"],
+ ["\"Clio and the Economics of QWERTY\"", "<i>American Economic Review</i>"],
+ ["\"The Fable of the Keys\"", "<i>Journal of Law and Economics</i>"],
["<i>Mastering the Dynamics of Innovation</i>", "Boston: Harvard Business School Press"],
["<i>Ingenious Yankees</i>", "New York: Columbia University Press"],
["<i>Woman's Place Is at the Typewriter</i>", "Philadelphia: Temple University Press"],
@@ -210,10 +210,10 @@ ${[
["<i>The Iron Whim: A Fragmented History of Typewriting</i>", "Ithaca: Cornell University Press"],
["<i>The Typewriter Legend</i>", "Secaucus, NJ: Matsushita Electric"],
["<i>The Wonderful Writing Machine</i>", "New York: Random House"],
- ['"The keyboard that would not die"', "<i>Smithsonian Magazine</i>"],
+ ["\"The keyboard that would not die\"", "<i>Smithsonian Magazine</i>"],
["<i>The Story of the Typewriter, 1873–1923</i>", "Herkimer, NY"],
- ['"How the typewriter changed office work"', "<i>The Atlantic</i>"],
- ['"Mistake Out: the invention of correction fluid"', "<i>Texas Monthly</i>"],
+ ["\"How the typewriter changed office work\"", "<i>The Atlantic</i>"],
+ ["\"Mistake Out: the invention of correction fluid\"", "<i>Texas Monthly</i>"],
];
const out = [];
for (let i = 0; i < 38; i++) {
@@ -221,7 +221,7 @@ ${[
const [t, p] = titles[(i * 11 + 3) % titles.length];
const y = 1923 + ((i * 37) % 98);
const pg = 12 + ((i * 53) % 290);
- const back = i % 4 === 1 ? '<span class="up">^ <sup>a</sup> <sup>b</sup></span>' : '<span class="up">^</span>';
+ const back = i % 4 === 1 ? "<span class=\"up\">^ <sup>a</sup> <sup>b</sup></span>" : "<span class=\"up\">^</span>";
const isbn = i % 3 === 0 ? ` ISBN 978-0-${String(100000 + i * 7919).slice(0, 3)}-${String(10000 + i * 3571).slice(0, 5)}-${i % 10}.` : "";
out.push(`<li>${back}${a} (${y}). ${t}. ${p}. p. ${pg}.${isbn}${i % 5 === 2 ? " Retrieved 14 March 2024." : ""}</li>`);
}
@@ -245,7 +245,7 @@ ${[
function figure(key) {
const f = FIGS[key];
- return `<div class="thumb" style="width:${f.w + 2}px"><svg viewBox="0 0 ${f.w} ${f.h}" width="${f.w}" height="${f.h}" ${key === "production" || key === "typebar" || key === "keyboard" ? "" : 'filter="url(#grain)"'}>${f.svg}</svg><div class="cap">${f.cap}</div></div>`;
+ return `<div class="thumb" style="width:${f.w + 2}px"><svg viewBox="0 0 ${f.w} ${f.h}" width="${f.w}" height="${f.h}" ${key === "production" || key === "typebar" || key === "keyboard" ? "" : "filter=\"url(#grain)\""}>${f.svg}</svg><div class="cap">${f.cap}</div></div>`;
}
const article = document.getElementById("article");
@@ -253,7 +253,7 @@ ${[
let h2n = 0;
let h3n = 0;
let html = "";
- const tocItems = ['<li class="top">(Top)</li>'];
+ const tocItems = ["<li class=\"top\">(Top)</li>"];
for (const sec of window.ARTICLE) {
let body = sec.html
.replace(/\{fig:(\w+)\}/g, (_, k) => figure(k))
diff --git a/capcodec/bench/corpus/pages/common/workbench.js b/capcodec/bench/corpus/pages/common/workbench.js
index 8dc32bd35..1a5d9d95a 100644
--- a/capcodec/bench/corpus/pages/common/workbench.js
+++ b/capcodec/bench/corpus/pages/common/workbench.js
@@ -1,33 +1,33 @@
(() => {
const ICONS = {
- files: '<path d="M14 3H8a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V8z"/><path d="M14 3v5h5"/><path d="M4 7v13a1 1 0 0 0 1 1h10"/>',
- search: '<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5 21 21"/>',
- scm: '<circle cx="6.5" cy="5" r="2"/><circle cx="6.5" cy="19" r="2"/><circle cx="17.5" cy="8" r="2"/><path d="M6.5 7v10"/><path d="M17.5 10c0 4.5-5 3.5-10 7.5"/>',
- run: '<path d="M7 4.5v15l12-7.5z"/><circle cx="18" cy="18" r="3"/>',
- ext: '<rect x="3.5" y="10.5" width="5" height="5"/><rect x="8.5" y="10.5" width="5" height="5"/><rect x="3.5" y="15.5" width="5" height="5"/><rect x="8.5" y="15.5" width="5" height="5"/><rect x="14.5" y="3.5" width="5" height="5" transform="rotate(12 17 6)"/>',
- test: '<path d="M9 3v6l-5 9a2 2 0 0 0 2 3h12a2 2 0 0 0 2-3l-5-9V3"/><path d="M8 3h8"/>',
- account: '<circle cx="12" cy="8.5" r="4"/><path d="M4 21c1-4.5 4.5-6.5 8-6.5s7 2 8 6.5"/>',
- gear: '<circle cx="12" cy="12" r="3"/><path d="M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1"/>',
- split: '<rect x="3.5" y="4.5" width="17" height="15" rx="1"/><path d="M12 4.5v15"/>',
- more: '<circle cx="6" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="18" cy="12" r="1"/>',
- branch: '<circle cx="6" cy="5" r="2"/><circle cx="6" cy="19" r="2"/><circle cx="18" cy="7" r="2"/><path d="M6 7v10M18 9c0 4-5 4-11 8"/>',
- sync: '<path d="M4 12a8 8 0 0 1 14-5.3M20 12a8 8 0 0 1-14 5.3"/><path d="M18 3v4h-4M6 21v-4h4"/>',
- err: '<circle cx="12" cy="12" r="8"/><path d="M9 9l6 6M15 9l-6 6"/>',
- warn: '<path d="M12 4 21 20H3z"/><path d="M12 10v5M12 17.5v.5"/>',
- bell: '<path d="M6 16V11a6 6 0 0 1 12 0v5l2 2H4z"/><path d="M10 20a2 2 0 0 0 4 0"/>',
- layout1: '<rect x="3.5" y="4.5" width="17" height="15" rx="1"/><path d="M9 4.5v15"/>',
- layout2: '<rect x="3.5" y="4.5" width="17" height="15" rx="1"/><path d="M3.5 14h17"/>',
- layout3: '<rect x="3.5" y="4.5" width="17" height="15" rx="1"/><path d="M15 4.5v15"/>',
- newfile: '<path d="M13 3H7a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V8z"/><path d="M12 11v6M9 14h6"/>',
- refresh: '<path d="M19 12a7 7 0 1 1-2-5"/><path d="M19 4v4h-4"/>',
- collapse: '<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M8 12h8"/>',
- close: '<path d="M6 6l12 12M18 6 6 18"/>',
- min: '<path d="M5 12h14"/>',
- max: '<rect x="6" y="6" width="12" height="12"/>',
- trash: '<path d="M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13"/>',
- plus: '<path d="M12 5v14M5 12h14"/>',
- chevup: '<path d="M6 15l6-6 6 6"/>',
- term: '<rect x="3.5" y="4.5" width="17" height="15" rx="1"/><path d="M7 9l3 3-3 3M12 15h5"/>',
+ files: "<path d=\"M14 3H8a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V8z\"/><path d=\"M14 3v5h5\"/><path d=\"M4 7v13a1 1 0 0 0 1 1h10\"/>",
+ search: "<circle cx=\"10.5\" cy=\"10.5\" r=\"6.5\"/><path d=\"M15.5 15.5 21 21\"/>",
+ scm: "<circle cx=\"6.5\" cy=\"5\" r=\"2\"/><circle cx=\"6.5\" cy=\"19\" r=\"2\"/><circle cx=\"17.5\" cy=\"8\" r=\"2\"/><path d=\"M6.5 7v10\"/><path d=\"M17.5 10c0 4.5-5 3.5-10 7.5\"/>",
+ run: "<path d=\"M7 4.5v15l12-7.5z\"/><circle cx=\"18\" cy=\"18\" r=\"3\"/>",
+ ext: "<rect x=\"3.5\" y=\"10.5\" width=\"5\" height=\"5\"/><rect x=\"8.5\" y=\"10.5\" width=\"5\" height=\"5\"/><rect x=\"3.5\" y=\"15.5\" width=\"5\" height=\"5\"/><rect x=\"8.5\" y=\"15.5\" width=\"5\" height=\"5\"/><rect x=\"14.5\" y=\"3.5\" width=\"5\" height=\"5\" transform=\"rotate(12 17 6)\"/>",
+ test: "<path d=\"M9 3v6l-5 9a2 2 0 0 0 2 3h12a2 2 0 0 0 2-3l-5-9V3\"/><path d=\"M8 3h8\"/>",
+ account: "<circle cx=\"12\" cy=\"8.5\" r=\"4\"/><path d=\"M4 21c1-4.5 4.5-6.5 8-6.5s7 2 8 6.5\"/>",
+ gear: "<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1\"/>",
+ split: "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"1\"/><path d=\"M12 4.5v15\"/>",
+ more: "<circle cx=\"6\" cy=\"12\" r=\"1\"/><circle cx=\"12\" cy=\"12\" r=\"1\"/><circle cx=\"18\" cy=\"12\" r=\"1\"/>",
+ branch: "<circle cx=\"6\" cy=\"5\" r=\"2\"/><circle cx=\"6\" cy=\"19\" r=\"2\"/><circle cx=\"18\" cy=\"7\" r=\"2\"/><path d=\"M6 7v10M18 9c0 4-5 4-11 8\"/>",
+ sync: "<path d=\"M4 12a8 8 0 0 1 14-5.3M20 12a8 8 0 0 1-14 5.3\"/><path d=\"M18 3v4h-4M6 21v-4h4\"/>",
+ err: "<circle cx=\"12\" cy=\"12\" r=\"8\"/><path d=\"M9 9l6 6M15 9l-6 6\"/>",
+ warn: "<path d=\"M12 4 21 20H3z\"/><path d=\"M12 10v5M12 17.5v.5\"/>",
+ bell: "<path d=\"M6 16V11a6 6 0 0 1 12 0v5l2 2H4z\"/><path d=\"M10 20a2 2 0 0 0 4 0\"/>",
+ layout1: "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"1\"/><path d=\"M9 4.5v15\"/>",
+ layout2: "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"1\"/><path d=\"M3.5 14h17\"/>",
+ layout3: "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"1\"/><path d=\"M15 4.5v15\"/>",
+ newfile: "<path d=\"M13 3H7a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V8z\"/><path d=\"M12 11v6M9 14h6\"/>",
+ refresh: "<path d=\"M19 12a7 7 0 1 1-2-5\"/><path d=\"M19 4v4h-4\"/>",
+ collapse: "<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"1\"/><path d=\"M8 12h8\"/>",
+ close: "<path d=\"M6 6l12 12M18 6 6 18\"/>",
+ min: "<path d=\"M5 12h14\"/>",
+ max: "<rect x=\"6\" y=\"6\" width=\"12\" height=\"12\"/>",
+ trash: "<path d=\"M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13\"/>",
+ plus: "<path d=\"M12 5v14M5 12h14\"/>",
+ chevup: "<path d=\"M6 15l6-6 6 6\"/>",
+ term: "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"1\"/><path d=\"M7 9l3 3-3 3M12 15h5\"/>",
};
const icon = (name, extra) => `<svg class="ic ${extra || ""}" viewBox="0 0 24 24">${ICONS[name] || ""}</svg>`;
window.wbIcon = icon;
@@ -73,7 +73,7 @@
return `<div class="tab${t.active ? " active" : ""}${t.preview ? " preview" : ""}" data-name="${t.name}"><span class="fi" style="color:${color};font:700 10px 'DejaVu Sans Mono'">${glyph}</span><span class="${t.preview ? "it" : ""}">${t.name}</span><span class="x">${t.active ? "×" : ""}</span></div>`;
})
.join("");
- const crumbs = cfg.crumbs.map((c, i) => `<span>${c}</span>${i < cfg.crumbs.length - 1 ? '<span class="sep">❯</span>' : ""}`).join("");
+ const crumbs = cfg.crumbs.map((c, i) => `<span>${c}</span>${i < cfg.crumbs.length - 1 ? "<span class=\"sep\">❯</span>" : ""}`).join("");
document.body.innerHTML = `
<div id="wb">
<div id="titlebar">
@@ -105,7 +105,7 @@
<div id="tabs">${tabs}<div class="tacts">${icon("run")}${icon("split")}${icon("more")}</div></div>
<div id="crumbs">${crumbs}</div>
<div id="editor"></div>
- ${cfg.panel ? '<div id="panel"></div>' : ""}
+ ${cfg.panel ? "<div id=\"panel\"></div>" : ""}
</div>
</div>
<div id="statusbar">
diff --git a/capcodec/bench/harness/runner.py b/capcodec/bench/harness/runner.py
index f88538c4c..74616e8f8 100644
--- a/capcodec/bench/harness/runner.py
+++ b/capcodec/bench/harness/runner.py
@@ -636,8 +636,9 @@ def gate(summary: dict, best: dict | None) -> tuple[bool, list[str]]:
if v.get("errors"):
ok = False
msgs.append(f"FAIL {e}: {v['errors']} encodes errored")
- if s is None:
- msgs.append(f"{GATE_ENCODER} not run; gate checks decode only")
+ if s is None or REFERENCE not in summary:
+ ok = False
+ msgs.append(f"FAIL {GATE_ENCODER} and {REFERENCE} must both run")
return ok, msgs
bd = s.get(f"bd_psnr_yuv_vs_{REFERENCE}")
fps = s.get("cpu_fps_median")
diff --git a/capcodec/bench/integration/media-server-driver.ts b/capcodec/bench/integration/media-server-driver.ts
index f38bc1946..44852d663 100644
--- a/capcodec/bench/integration/media-server-driver.ts
+++ b/capcodec/bench/integration/media-server-driver.ts
@@ -1,5 +1,5 @@
-import { processVideo } from "/workspace/apps/media-server/src/lib/media-video";
-import { probeVideoFile } from "/workspace/apps/media-server/src/lib/media-probe";
+import { processVideo } from "../../../apps/media-server/src/lib/media-video";
+import { probeVideoFile } from "../../../apps/media-server/src/lib/media-probe";
const [input, output] = process.argv.slice(2);
if (!input || !output) {
diff --git a/capcodec/bench/speedcmp.py b/capcodec/bench/speedcmp.py
index ddcf077e9..a08493a1e 100644
--- a/capcodec/bench/speedcmp.py
+++ b/capcodec/bench/speedcmp.py
@@ -341,6 +341,7 @@ def main() -> None:
runs: dict[str, list[dict]] = {}
jobs = []
for t in threads:
+ # Counts above 1 keep the published table: x264 uses -threads 0 (automatic).
jobs.append((f"x264_t{t}", x264_cmd(src, a.x264_crf, mode, 0 if t > 1 else 1, work / "x.mp4",
a.keyint1)))
jobs.append((f"cap_t{t}", capcodec_cmd(a.binary, src, m["crf"], mode, t, work / "c.mp4",
@@ -369,7 +370,9 @@ def main() -> None:
def write_report(results: dict, path: Path, threads: list[int]) -> None:
lines = ["# Speed at matched VMAF vs x264 (interleaved, other work paused during each timed run)", "",
- "Ratio = x264 / capcodec (above 1 means capcodec is faster). Medians over rounds.", ""]
+ "Ratio = x264 / capcodec (above 1 means capcodec is faster). Medians over rounds.",
+ "A thread count of 1 limits both encoders to one thread. A higher count limits capcodec to that count and runs x264 with `-threads 0` (automatic).",
+ ""]
head = "| clip | mode | VMAF | capcodec crf | kbps vs x264 |"
sep = "|---|---|---|---|---|"
for t in threads: