GPU VMAF: decode the AV1 test encode on the A580 too #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "perf/gpu-vmaf-decode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Requested by Kees
What
With GPU VMAF and the qsv encoder, the AV1 test encode is decoded by the A580 (av1_qsv, hwdownload to p010le) before libvmaf_sycl, instead of dav1d on the CPU. The lossless reference stays a CPU read (cheap), and the one-time CPU self-check keeps CPU decoding, so a GPU decode difference would be caught.
Tests
🤖 Generated with Claude Code
Title
GPU VMAF: decode the AV1 test encode on the A580 too
PR Type
Enhancement
Description
Enable QSV GPU decoding for AV1 test encodes in VMAF checks.
Achieve identical scores with ~20% less CPU per quality search.
Add unit tests to verify QSV decode flags and CPU fallback.
Diagram Walkthrough
File Walkthrough
rx_media.py
Add QSV device support and hardware decode flags to VMAF commandbuilderapp/rx_media.py
qsv_deviceparameter tovmaf_cmdfunction.encoded stream when specified.
hardware acceleration for decoding.
rx_search.py
Integrate QSV device selection into GPU VMAF scoring logicapp/rx_search.py
qsv_deviceconfiguration tovmaf_cmdwhen using GPU scoring.qsv) and hardwaredecode setting.
test_gpu_vmaf.py
Add unit tests for QSV decode command generation and CPU fallbacktests/test_gpu_vmaf.py
test_cmd_qsv_decodeto verify QSV-specific flags are present inthe command.
CHANGELOG.md
Update changelog with QSV decode feature and performance metricsCHANGELOG.md
usage.
3 finding(s) as line comments; the review comment lists all of them.
@ -445,6 +449,8 @@ def vmaf_cmd(encoded: str, ref: str, threads: int, log: Optional[str] = None, heVMAF_GPU_FFMPEG if gpu else "ffmpeg","-nostdin","-nostats", # the score is logged at info level; progress lines only buried the real error] + (["-init_hw_device", f"qsv=hw:{qsv_device}", "-hwaccel", "qsv", "-hwaccel_output_format", "qsv",Incorrect FFmpeg Argument Order ·
KK-e57fe08f18· lowThe added arguments for QSV hardware acceleration (-init_hw_device, -hwaccel, etc.) are inserted before the first input file (-i). While this is generally correct for hwaccel, the test at line 54 of tests/test_gpu_vmaf.py asserts that the index of -hwaccel is less than -i. However, the actual command construction adds these flags after the vmaf_cmd function call arguments but before the inputs. The logic seems sound for the first input, but if multiple inputs were ever passed, only the first would be affected by the hwaccel chain defined here, potentially causing issues with the reference stream if it were also expected to be hardware decoded (though the diff shows it is not).
Reply
not an issue,false positiveorwon't fixto dismiss it; it is then not reported again.@ -225,3 +225,3 @@if (cfg.get("vmaf_gpu", "auto") != "off" and _gpu_vmaf["ok"] is not False and (height or 0) >= GPU_MIN_HEIGHTand os.path.exists(rx_media.VMAF_GPU_FFMPEG)):rc, _, err = run(rx_media.vmaf_cmd(enc, ref, threads, log, height, gpu=True))qsv = cfg.get("device") if cfg.get("encoder") == "qsv" and cfg.get("hw_decode", True) else NoneLogic Error in QSV Device Selection ·
KK-42ec94f1e3· mediumThe code checks if the encoder is "qsv" to decide whether to use QSV for decoding. However, the PR description and tests specifically target AV1 encoding ("av1_qsv"). If a user configures a different qsv encoder (e.g., h264_qsv), this logic would incorrectly attempt to decode that stream using QSV hardware acceleration, which may not be supported or intended for all codecs.
Reply
not an issue,false positiveorwon't fixto dismiss it; it is then not reported again.@ -51,1 +51,4 @@def test_cmd_qsv_decode(self):c = rx_media.vmaf_cmd("/w/e.mkv", "/w/r.mkv", 3, None, 1080, gpu=True, qsv_device="/dev/dri/renderD128")self.assertLess(c.index("-hwaccel"), c.index("-i")) # only the encode (first input) is decoded on the GPUTest Assertion Reliability ·
KK-4e0d72164a· lowThe test at line 54 asserts that the index of "-hwaccel" is less than the index of "-i". This relies on the specific order of arguments generated by vmaf_cmd. If future changes alter the argument insertion point or if the ffmpeg version behaves differently regarding argument parsing order, this assertion might fail even if the functionality works correctly. It is better to verify the presence of the flags relative to the specific input stream they are meant to affect rather than global index comparison.
Reply
not an issue,false positiveorwon't fixto dismiss it; it is then not reported again.PR Reviewer Guide 🔍
📋 Focus areas: 🔴 3 open · ✅ 0 handled. Every push re-checks them; a handled area moves to Resolved findings at the bottom.
Logic Error in QSV Device Selection
The code checks if the encoder is "qsv" to decide whether to use QSV for decoding. However, the PR description and tests specifically target AV1 encoding ("av1_qsv"). If a user configures a different qsv encoder (e.g., h264_qsv), this logic would incorrectly attempt to decode that stream using QSV hardware acceleration, which may not be supported or intended for all codecs.
Incorrect FFmpeg Argument Order
The added arguments for QSV hardware acceleration (-init_hw_device, -hwaccel, etc.) are inserted before the first input file (-i). While this is generally correct for hwaccel, the test at line 54 of tests/test_gpu_vmaf.py asserts that the index of -hwaccel is less than -i. However, the actual command construction adds these flags after the vmaf_cmd function call arguments but before the inputs. The logic seems sound for the first input, but if multiple inputs were ever passed, only the first would be affected by the hwaccel chain defined here, potentially causing issues with the reference stream if it were also expected to be hardware decoded (though the diff shows it is not).
Test Assertion Reliability
The test at line 54 asserts that the index of "-hwaccel" is less than the index of "-i". This relies on the specific order of arguments generated by vmaf_cmd. If future changes alter the argument insertion point or if the ffmpeg version behaves differently regarding argument parsing order, this assertion might fail even if the functionality works correctly. It is better to verify the presence of the flags relative to the specific input stream they are meant to affect rather than global index comparison.
🗂️ Finding ids (reply with the id and
not an issue,false positiveorwon't fixto dismiss one; it is then not reported again):KK-42ec94f1e3app/rx_search.py:227KK-e57fe08f18app/rx_media.py:452KK-4e0d72164atests/test_gpu_vmaf.py:54