Repository navigation
media: apple: ave: constant-quality rate control - #1128
Closed
RyanTheTide wants to merge 1 commit into
Closed
RyanTheTide wants to merge 1 commit into
RyanTheTide wants to merge 1 commit into
Conversation
Offer V4L2_MPEG_VIDEO_BITRATE_MODE_CQ with V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY (0-100, 100 best). The session and frame writers already carry the constant-quality layout (rate-control mode 3); what was missing was the quality-to-QP mapping. Measured on macOS 27.0 on the M4 Pro from the slice QPs of its own VideoToolbox output at every quality step 0.00-1.00 (H.264 and HEVC agree, and so do the J700 captures at 0.30, 0.60 and 0.90): one QP for every frame, capped at 48. Use the same table, no data-rate limit, and twice the coded-data capacity, as macOS allows. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Contributor
Author
|
Same-chip comparison on the J616s (M4 Pro). Linux:
Data: work/avd/AVX/linux-j616s/{cq-j616s,cq-j616s.log,speed-psnr-j6pm.txt} on the S500. |
This was referenced Nov 8, 2026
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds constant-quality rate control to the AVE encoder:
V4L2_MPEG_VIDEO_BITRATE_MODE_CQwithV4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY(0-100, 100 best, default 50). This is the one rate-control mode macOS offers (VideoToolboxkVTCompressionPropertyKey_Quality) that Linux refused until now.The session and frame writers already had the constant-quality layout (rate-control mode 3); the driver refused CQ only because the quality-to-QP mapping was unknown. That mapping is now measured: on macOS 27.0 on the M4 Pro, VideoToolbox encodes every frame of a constant-quality session with one QP, and reading the slice QPs of its own output at every step from 0.00 to 1.00 gives the table in
ave_cq_qp[](H.264 and HEVC give the same values; the earlier J700 captures at 0.30, 0.60 and 0.90 agree: QP 40, 28, 10; the QP never exceeds 48). HEVC constant-quality frame sizes differ from macOS (7092 vs 8301 bytes at quality 30) on the Neo and on the J616s alike, at the same QP, because macOS HEVC P-frames use weighted prediction; H.264 matches to the picture.Validation
7.3.0-aurora-fleet23+ this driver as a signed module on a fresh boot, 1080p, 150 frames of identical raw input (Mandelbrot zoom with temporal grain), GOP 30, no B-frames. Average H.264 frame sizes equal to macOS 27.0 on the M4 Pro for the same input and quality: 13311/27508/61771/233554 bytes on Linux vs 13312/27509/61772/233555 on macOS at quality 30/45/60/75 (the averages are rounded differently). The bitstreams carry exactly the table's QP.checkpatch.pl --strictclean.Benchmarks (Neo, CQ, 1080p, fps)
Still a draft until the HEVC and J616s rows are in.
🤖 Generated with Claude Code