VMAF on the Intel GPU with the kk-vmafx base image, checked against the CPU #5

Merged
khyretos merged 1 commit from feat/gpu-vmaf into main 2026-11-02 03:05:29 +01:00
Owner

Requested by Kees

What

  • RX_BASE_IMAGE build arg (default debian:trixie-slim, unchanged). With kk-vmafx:local the image is Ubuntu 26.04 + Intel GPU runtime + VMAFx ffmpeg (/opt/vmafx/bin/ffmpeg); everything except VMAF keeps the BtbN ffmpeg.
  • Quality checks of 720p and up are scored with libvmaf_sycl on the A580, every frame. First GPU score per start is compared with the CPU scoring every frame on the same pair; only a match within 0.01 switches to the GPU. Mismatch or GPU error: CPU. RX_VMAF_GPU=off disables it.
  • Below 720p stays on the CPU (480p: 568 s CPU on the GPU path vs 101 s).
  • Status line shows where checks are scored.

Tests

  • Unit tests green (new test_gpu_vmaf: cmd, self-check match/mismatch/error, SD on CPU, off/missing).
  • Real episodes in a throwaway container on the A580 (search with 5 trials x 3 samples), CPU vs this branch:
    • 8-bit H.264 1080p: q22, ratio 0.587 both; CPU 621 s -> 509 s (incl. the one-time 60 s self-check); wall 176 -> 144 s
    • 10-bit HEVC 1080p: q24, ratio 0.336 both; CPU 632 s -> 542 s; wall 173 -> 154 s
    • AVI 480p: identical (CPU path), 106 s
    • Self-check: gpu 95.945029 = cpu 95.945029
  • Paused preview on a DB copy with the new base: healthy, UI smoke check passes.

🤖 Generated with Claude Code

<!-- claude-projects-attribution: {"github_login":"Khyretos"} --> _Requested by **Kees**_ ## What - `RX_BASE_IMAGE` build arg (default debian:trixie-slim, unchanged). With `kk-vmafx:local` the image is Ubuntu 26.04 + Intel GPU runtime + VMAFx ffmpeg (`/opt/vmafx/bin/ffmpeg`); everything except VMAF keeps the BtbN ffmpeg. - Quality checks of 720p and up are scored with `libvmaf_sycl` on the A580, every frame. First GPU score per start is compared with the CPU scoring every frame on the same pair; only a match within 0.01 switches to the GPU. Mismatch or GPU error: CPU. `RX_VMAF_GPU=off` disables it. - Below 720p stays on the CPU (480p: 568 s CPU on the GPU path vs 101 s). - Status line shows where checks are scored. ## Tests - Unit tests green (new test_gpu_vmaf: cmd, self-check match/mismatch/error, SD on CPU, off/missing). - Real episodes in a throwaway container on the A580 (search with 5 trials x 3 samples), CPU vs this branch: - 8-bit H.264 1080p: q22, ratio 0.587 both; CPU 621 s -> 509 s (incl. the one-time 60 s self-check); wall 176 -> 144 s - 10-bit HEVC 1080p: q24, ratio 0.336 both; CPU 632 s -> 542 s; wall 173 -> 154 s - AVI 480p: identical (CPU path), 106 s - Self-check: gpu 95.945029 = cpu 95.945029 - Paused preview on a DB copy with the new base: healthy, UI smoke check passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
RX_BASE_IMAGE=kk-vmafx:local builds on Ubuntu 26.04 with the Intel GPU runtime and
VMAFx's ffmpeg (libvmaf_sycl) under /opt/vmafx. Quality checks of 720p and up are
then scored on the A580, every frame (its n_subsample > 1 is broken). The first GPU
score of each start is compared with the CPU scoring every frame on the same pair;
only a match (within 0.01) switches to the GPU, a mismatch or error stays on the CPU.
The status line says where checks are scored. Default base is unchanged.

Real episodes: same chosen quality and ratio, ~20% less CPU, faster.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator

Title

VMAF on the Intel GPU with the kk-vmafx base image, checked against the CPU


PR Type

Enhancement


Description

  • Adds Intel GPU VMAF scoring for 720p+ videos

  • Switches to GPU only after matching CPU score

  • Includes unit tests and UI status updates


Diagram Walkthrough

flowchart LR
  A["User Request"] -->|"Check Config"| B["GPU Enabled?"]
  B -->|"Height < 720"| C["Use CPU"]
  B -->|"Height >= 720"| D["First Score Check"]
  D -->|"GPU == CPU"| E["Use GPU"]
  D -->|"Mismatch/Error"| F["Use CPU"]
  E -.->|"Subsequent Scores"| G["GPU Only"]
  F -.->|"Subsequent Scores"| H["CPU Only"]

File Walkthrough

Relevant files
Enhancement
3 files
rx_app.py
Add vmaf_on status indicator to app state                               
+8/-0     
rx_media.py
Support GPU VMAF command with libvmaf_sycl                             
+14/-3   
rx_search.py
Implement GPU VMAF logic with CPU validation                         
+39/-5   
Configuration changes
3 files
rx_config.py
Parse RX_VMAF_GPU environment variable                                     
+4/-0     
Dockerfile
Support custom base image for GPU runtime                               
+10/-4   
docker-compose.yml
Pass RX_BASE_IMAGE and RX_VMAF_GPU args                                   
+2/-0     
Tests
1 files
test_gpu_vmaf.py
Add unit tests for GPU VMAF functionality                               
+91/-0   
Documentation
4 files
app.js
Display VMAF scoring location in UI                                           
+3/-0     
.env.example
Document new RX_VMAF_GPU setting                                                 
+4/-0     
CHANGELOG.md
Document Intel GPU VMAF feature release                                   
+2/-0     
README.md
Update env vars documentation for GPU                                       
+2/-0     

## Title <!-- pr-agent:describe:persistent --> VMAF on the Intel GPU with the kk-vmafx base image, checked against the CPU ___ ### **PR Type** Enhancement ___ ### **Description** - Adds Intel GPU VMAF scoring for 720p+ videos - Switches to GPU only after matching CPU score - Includes unit tests and UI status updates ___ ### Diagram Walkthrough ```mermaid flowchart LR A["User Request"] -->|"Check Config"| B["GPU Enabled?"] B -->|"Height < 720"| C["Use CPU"] B -->|"Height >= 720"| D["First Score Check"] D -->|"GPU == CPU"| E["Use GPU"] D -->|"Mismatch/Error"| F["Use CPU"] E -.->|"Subsequent Scores"| G["GPU Only"] F -.->|"Subsequent Scores"| H["CPU Only"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>3 files</summary><table> <tr> <td><strong>rx_app.py</strong><dd><code>Add vmaf_on status indicator to app state</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/app/rx_app.py">+8/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>rx_media.py</strong><dd><code>Support GPU VMAF command with libvmaf_sycl</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/app/rx_media.py">+14/-3</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>rx_search.py</strong><dd><code>Implement GPU VMAF logic with CPU validation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/app/rx_search.py">+39/-5</a>&nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>3 files</summary><table> <tr> <td><strong>rx_config.py</strong><dd><code>Parse RX_VMAF_GPU environment variable</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/app/rx_config.py">+4/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>Dockerfile</strong><dd><code>Support custom base image for GPU runtime</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/Dockerfile">+10/-4</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>docker-compose.yml</strong><dd><code>Pass RX_BASE_IMAGE and RX_VMAF_GPU args</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/docker-compose.yml">+2/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>test_gpu_vmaf.py</strong><dd><code>Add unit tests for GPU VMAF functionality</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/tests/test_gpu_vmaf.py">+91/-0</a>&nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>app.js</strong><dd><code>Display VMAF scoring location in UI</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/app/static/app.js">+3/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>.env.example</strong><dd><code>Document new RX_VMAF_GPU setting</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/.env.example">+4/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>CHANGELOG.md</strong><dd><code>Document Intel GPU VMAF feature release</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/CHANGELOG.md">+2/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>README.md</strong><dd><code>Update env vars documentation for GPU</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/README.md">+2/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> </details> ___
kompas-review left a comment

3 finding(s) as line comments; the review comment lists all of them.

3 finding(s) as line comments; the review comment lists all of them.
@ -209,0 +224,4 @@
threads, height = cfg["vmaf_threads"], info.get("height")
if (cfg.get("vmaf_gpu", "auto") != "off" and _gpu_vmaf["ok"] is not False and (height or 0) >= GPU_MIN_HEIGHT
and os.path.exists(rx_media.VMAF_GPU_FFMPEG)):
rc, _, err = run(rx_media.vmaf_cmd(enc, ref, threads, log, height, gpu=True))
Collaborator

Unbounded Recursion Risk · KK-f1a1d61e69 · low

The _vmaf_score function calls itself recursively via the run() callable when executing GPU VMAF checks (line 227) and CPU fallbacks (line 241). If the run() callable is misconfigured to invoke _vmaf_score instead of an external process, this creates infinite recursion leading to a stack overflow. While unlikely in normal operation, the lack of explicit process separation in the code structure makes this a latent risk.

Reply not an issue, false positive or won't fix to dismiss it; it is then not reported again.

**Unbounded Recursion Risk** · `KK-f1a1d61e69` · low The _vmaf_score function calls itself recursively via the run() callable when executing GPU VMAF checks (line 227) and CPU fallbacks (line 241). If the run() callable is misconfigured to invoke _vmaf_score instead of an external process, this creates infinite recursion leading to a stack overflow. While unlikely in normal operation, the lack of explicit process separation in the code structure makes this a latent risk. <sub>Reply `not an issue`, `false positive` or `won't fix` to dismiss it; it is then not reported again.</sub> <!-- kk-finding:f1a1d61e69 -->
@ -209,0 +236,4 @@
+ ("" if rc == 0 else f" ({describe_rc(rc)}: {useful_tail(err, 200)})"), file=sys.stderr, flush=True)
if score is not None and _gpu_vmaf["ok"]:
return score
if rc != 0 and not first: # a later GPU failure: this score comes from the CPU, the next one tries the GPU again
Collaborator

Missing Error Handling for parse_vmaf · KK-636033240b · medium

In _vmaf_score, if the GPU command fails (rc != 0), the code proceeds to call rx_media.parse_vmaf on the error output (line 241) without first checking if a valid score was obtained from the failed attempt. This could result in parsing garbage data or raising unexpected exceptions if parse_vmaf does not handle non-score output gracefully.

Reply not an issue, false positive or won't fix to dismiss it; it is then not reported again.

**Missing Error Handling for parse_vmaf** · `KK-636033240b` · medium In _vmaf_score, if the GPU command fails (rc != 0), the code proceeds to call rx_media.parse_vmaf on the error output (line 241) without first checking if a valid score was obtained from the failed attempt. This could result in parsing garbage data or raising unexpected exceptions if parse_vmaf does not handle non-score output gracefully. <sub>Reply `not an issue`, `false positive` or `won't fix` to dismiss it; it is then not reported again.</sub> <!-- kk-finding:636033240b -->
@ -0,0 +21,4 @@
def __call__(self, cmd, timeout=None, on_line=None):
self.cmds.append(cmd)
score = self.gpu if "libvmaf_sycl" in cmd[cmd.index("-lavfi") + 1] else self.cpu
Collaborator

Test Mock Inconsistency · KK-cf487d87c7 · low

The FakeRun mock in test_gpu_vmaf.py returns a score based on whether "libvmaf_sycl" is in the command string (line 24), but it does not simulate the actual behavior of the real ffmpeg binary which might fail with specific exit codes or produce different error messages. This could lead to false positives in tests where the mock succeeds but the real implementation would fail under similar conditions.

Reply not an issue, false positive or won't fix to dismiss it; it is then not reported again.

**Test Mock Inconsistency** · `KK-cf487d87c7` · low The FakeRun mock in test_gpu_vmaf.py returns a score based on whether "libvmaf_sycl" is in the command string (line 24), but it does not simulate the actual behavior of the real ffmpeg binary which might fail with specific exit codes or produce different error messages. This could lead to false positives in tests where the mock succeeds but the real implementation would fail under similar conditions. <sub>Reply `not an issue`, `false positive` or `won't fix` to dismiss it; it is then not reported again.</sub> <!-- kk-finding:cf487d87c7 -->
Collaborator

PR Reviewer Guide 🔍

📋 Focus areas: 🔴 3 open · ✅ 0 handled. Every push re-checks them; a handled area moves to Resolved findings at the bottom.

🔒 No security concerns identified
⚡ Recommended focus areas for review

Unbounded Recursion Risk

The _vmaf_score function calls itself recursively via the run() callable when executing GPU VMAF checks (line 227) and CPU fallbacks (line 241). If the run() callable is misconfigured to invoke _vmaf_score instead of an external process, this creates infinite recursion leading to a stack overflow. While unlikely in normal operation, the lack of explicit process separation in the code structure makes this a latent risk.

    rc, _, err = run(rx_media.vmaf_cmd(enc, ref, threads, log, height, gpu=True))
    score = rx_media.parse_vmaf(err) if rc == 0 else None
    first = _gpu_vmaf["ok"] is None
    if first:
        # first GPU score of this run: the CPU scores the same pair, every frame, and must agree
        cpu = rx_media.parse_vmaf(_run_ok(run, rx_media.vmaf_cmd(enc, ref, threads, None, height, subsample=1)))
        ok = score is not None and cpu is not None and abs(score - cpu) <= GPU_TOLERANCE
        _gpu_vmaf["ok"] = ok
        print(f"GPU VMAF check: gpu {score} cpu {cpu}: " + ("scoring on the GPU" if ok else "staying on the CPU")
              + ("" if rc == 0 else f" ({describe_rc(rc)}: {useful_tail(err, 200)})"), file=sys.stderr, flush=True)
    if score is not None and _gpu_vmaf["ok"]:
        return score
    if rc != 0 and not first:  # a later GPU failure: this score comes from the CPU, the next one tries the GPU again
        print(f"GPU VMAF failed ({describe_rc(rc)}: {useful_tail(err, 200)}), scored on the CPU", file=sys.stderr, flush=True)
score = rx_media.parse_vmaf(_run_ok(run, rx_media.vmaf_cmd(enc, ref, threads, log, height)))
Missing Error Handling for parse_vmaf

In _vmaf_score, if the GPU command fails (rc != 0), the code proceeds to call rx_media.parse_vmaf on the error output (line 241) without first checking if a valid score was obtained from the failed attempt. This could result in parsing garbage data or raising unexpected exceptions if parse_vmaf does not handle non-score output gracefully.

    if rc != 0 and not first:  # a later GPU failure: this score comes from the CPU, the next one tries the GPU again
        print(f"GPU VMAF failed ({describe_rc(rc)}: {useful_tail(err, 200)}), scored on the CPU", file=sys.stderr, flush=True)
score = rx_media.parse_vmaf(_run_ok(run, rx_media.vmaf_cmd(enc, ref, threads, log, height)))
Test Mock Inconsistency

The FakeRun mock in test_gpu_vmaf.py returns a score based on whether "libvmaf_sycl" is in the command string (line 24), but it does not simulate the actual behavior of the real ffmpeg binary which might fail with specific exit codes or produce different error messages. This could lead to false positives in tests where the mock succeeds but the real implementation would fail under similar conditions.

score = self.gpu if "libvmaf_sycl" in cmd[cmd.index("-lavfi") + 1] else self.cpu
if score is None:
    return 1, "", "No device of requested type available"
return 0, "", f"VMAF score: {score}\n"

🗂️ Finding ids (reply with the id and not an issue, false positive or won't fix to dismiss one; it is then not reported again):

  • KK-f1a1d61e69 app/rx_search.py:227
  • KK-636033240b app/rx_search.py:239
  • KK-cf487d87c7 tests/test_gpu_vmaf.py:24
## PR Reviewer Guide 🔍 <!-- pr-agent:review:full --> 📋 **Focus areas:** 🔴 3 open · ✅ 0 handled. Every push re-checks them; a handled area moves to *Resolved findings* at the bottom. <table> <tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr> <tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br> <details><summary><a href='https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/app/rx_search.py#L227-L241'><strong>Unbounded Recursion Risk</strong></a> The _vmaf_score function calls itself recursively via the run() callable when executing GPU VMAF checks (line 227) and CPU fallbacks (line 241). If the run() callable is misconfigured to invoke _vmaf_score instead of an external process, this creates infinite recursion leading to a stack overflow. While unlikely in normal operation, the lack of explicit process separation in the code structure makes this a latent risk. </summary> ```python rc, _, err = run(rx_media.vmaf_cmd(enc, ref, threads, log, height, gpu=True)) score = rx_media.parse_vmaf(err) if rc == 0 else None first = _gpu_vmaf["ok"] is None if first: # first GPU score of this run: the CPU scores the same pair, every frame, and must agree cpu = rx_media.parse_vmaf(_run_ok(run, rx_media.vmaf_cmd(enc, ref, threads, None, height, subsample=1))) ok = score is not None and cpu is not None and abs(score - cpu) <= GPU_TOLERANCE _gpu_vmaf["ok"] = ok print(f"GPU VMAF check: gpu {score} cpu {cpu}: " + ("scoring on the GPU" if ok else "staying on the CPU") + ("" if rc == 0 else f" ({describe_rc(rc)}: {useful_tail(err, 200)})"), file=sys.stderr, flush=True) if score is not None and _gpu_vmaf["ok"]: return score if rc != 0 and not first: # a later GPU failure: this score comes from the CPU, the next one tries the GPU again print(f"GPU VMAF failed ({describe_rc(rc)}: {useful_tail(err, 200)}), scored on the CPU", file=sys.stderr, flush=True) score = rx_media.parse_vmaf(_run_ok(run, rx_media.vmaf_cmd(enc, ref, threads, log, height))) ``` </details> <details><summary><a href='https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/app/rx_search.py#L239-L241'><strong>Missing Error Handling for parse_vmaf</strong></a> In _vmaf_score, if the GPU command fails (rc != 0), the code proceeds to call rx_media.parse_vmaf on the error output (line 241) without first checking if a valid score was obtained from the failed attempt. This could result in parsing garbage data or raising unexpected exceptions if parse_vmaf does not handle non-score output gracefully. </summary> ```python if rc != 0 and not first: # a later GPU failure: this score comes from the CPU, the next one tries the GPU again print(f"GPU VMAF failed ({describe_rc(rc)}: {useful_tail(err, 200)}), scored on the CPU", file=sys.stderr, flush=True) score = rx_media.parse_vmaf(_run_ok(run, rx_media.vmaf_cmd(enc, ref, threads, log, height))) ``` </details> <details><summary><a href='https://git.kreative-kompas.com/khyretos/kk-reencoder/src/branch/feat/gpu-vmaf/tests/test_gpu_vmaf.py#L24-L27'><strong>Test Mock Inconsistency</strong></a> The FakeRun mock in test_gpu_vmaf.py returns a score based on whether "libvmaf_sycl" is in the command string (line 24), but it does not simulate the actual behavior of the real ffmpeg binary which might fail with specific exit codes or produce different error messages. This could lead to false positives in tests where the mock succeeds but the real implementation would fail under similar conditions. </summary> ```python score = self.gpu if "libvmaf_sycl" in cmd[cmd.index("-lavfi") + 1] else self.cpu if score is None: return 1, "", "No device of requested type available" return 0, "", f"VMAF score: {score}\n" ``` </details> </td></tr> </table> <hr> 🗂️ **Finding ids** (reply with the id and `not an issue`, `false positive` or `won't fix` to dismiss one; it is then not reported again): - `KK-f1a1d61e69` `app/rx_search.py:227` - `KK-636033240b` `app/rx_search.py:239` - `KK-cf487d87c7` `tests/test_gpu_vmaf.py:24` <!-- pr-agent-review-state:v1 {"findings":[{"body":"**Unbounded Recursion Risk**\n\nThe _vmaf_score function calls itself recursively via the run() callable when executing GPU VMAF checks (line 227) and CPU fallbacks (line 241). If the run() callable is misconfigured to invoke _vmaf_score instead of an external process, this creates infinite recursion leading to a stack overflow. While unlikely in normal operation, the lack of explicit process separation in the code structure makes this a latent risk.","finding_id":"1ef415c1292d","first_seen":"2026-11-02T02:06:20.124270Z","last_seen":"2026-11-02T02:06:20.124270Z","last_seen_head_sha":"f8c9aeed306ad84144dc115348b8e9d608ba523a","line_end":241,"line_start":227,"path":"app/rx_search.py","state":"ACTIVE"},{"body":"**Test Mock Inconsistency**\n\nThe FakeRun mock in test_gpu_vmaf.py returns a score based on whether \"libvmaf_sycl\" is in the command string (line 24), but it does not simulate the actual behavior of the real ffmpeg binary which might fail with specific exit codes or produce different error messages. This could lead to false positives in tests where the mock succeeds but the real implementation would fail under similar conditions.","finding_id":"cd95c3445b04","first_seen":"2026-11-02T02:06:20.124270Z","last_seen":"2026-11-02T02:06:20.124270Z","last_seen_head_sha":"f8c9aeed306ad84144dc115348b8e9d608ba523a","line_end":27,"line_start":24,"path":"tests/test_gpu_vmaf.py","state":"ACTIVE"},{"body":"**Missing Error Handling for parse_vmaf**\n\nIn _vmaf_score, if the GPU command fails (rc != 0), the code proceeds to call rx_media.parse_vmaf on the error output (line 241) without first checking if a valid score was obtained from the failed attempt. This could result in parsing garbage data or raising unexpected exceptions if parse_vmaf does not handle non-score output gracefully.","finding_id":"eb07c793ef78","first_seen":"2026-11-02T02:06:20.124270Z","last_seen":"2026-11-02T02:06:20.124270Z","last_seen_head_sha":"f8c9aeed306ad84144dc115348b8e9d608ba523a","line_end":241,"line_start":239,"path":"app/rx_search.py","state":"ACTIVE"}],"last_run":{"complete":true,"excluded_files":[],"head_sha":"f8c9aeed306ad84144dc115348b8e9d608ba523a","kind":"full","run_id":"https://git.kreative-kompas.com/khyretos/kk-reencoder/commit/f8c9aeed306ad84144dc115348b8e9d608ba523a"},"schema_version":1} -->
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
khyretos/kk-reencoder!5
No description provided.