Skip to content

media: apple: ave: 26A428: encode HEVC Main 10 (on #2218) - #2547

Merged
RyanTheTide merged 4 commits into
aurora-silicon:mainfrom
m0d16l14n1:j815/t8142-ave-main10
Nov 26, 2026
Merged

RyanTheTide merged 4 commits into
aurora-silicon:mainfrom
m0d16l14n1:j815/t8142-ave-main10

Conversation

@m0d16l14n1

@m0d16l14n1 m0d16l14n1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What: HEVC Main 10 (P010 in) on the counted 26A428/26B123 layouts, keyed on the layout instead of the chip. Stacked on #2218: its three commits come first and drop out once it merges; the new commit is the last one.
Tested: J815 (MacBook Air 15" M5) at 8613fb37d28b: v4l2-ctl P010 → HEVC Main 10 with 3 B-frames at 12 Mb/s on a high-motion clip, every stream Main 10, yuv420p10le at the right frame count: 720p 37.3 dB 278 fps, 1080p 32.8 dB 238 fps, 2160p 34.5 dB 61 fps. Regression at boot: 0 SELinux denials (SELinux off), 0 failed units, 0 new kernel errors.
Risk: two-way door. AVE HEVC encode on 26A428 (M5, M5 Pro/Max) and 26B123 (M3/M4 27.2): P010 appears in their format list and a new context starts on HEVC, as on 9003. The 9003 chips take the same path as before.
Not yet: 26B123 (M3 J615 / M4 J713) Main 10 encode plus a GStreamer v4l2h264enc check; 9003 no-regression rows (A18 Pro / M4 Pro); optionally T6050 (J714s).

Details

The counted (26A428) layout refused Main 10, so on the M5 S_FMT turned P010 into NV12 and a Main 10 profile failed at STREAMON.

Why the layout can do it: its Start already maps every word the 9003 Main 10 capture changes with bit depth: the 8-bit flag (0x35e8), the QP floors, the bit depth (0x37c0), both profile/compat groups and the SPS luma/chroma depth. A KUnit case, ave_26a428_hevc_main10, builds a Main 10 Start on 26A428 and 26B123 and checks those words against the 8-bit one.

The change: Main 10 is admitted for the layout. It lifts the refusal in the session setup, and ave_main10_supported() becomes "9003 or counted", so P010 is listed for HEVC and Main 10 appears in the profile menu. As on 9003, a new context starts on HEVC, so a client that probes raw formats first (GStreamer) sees P010; clients that set the coded format are unaffected.

Changed on this head: rebased onto main with #2218's rebased commits. No AI attribution in the body or the commits.

Evidence

J815, macOS 27.2 stub, this head merged with the other J815 PRs into one test kernel on main 2943fff. Source: parkjoy (high motion) as P010, padded to the driver's sizeimage (16-row aligned); hevc_profile=2, video_b_frames=3, 12 Mb/s. PSNR against the tight source frames.

size frames stream PSNR speed
1280x720 30 Main 10, yuv420p10le 37.3 dB 278 fps
1920x1080 120 Main 10, yuv420p10le 32.8 dB 238 fps
3840x2160 30 Main 10, yuv420p10le 34.5 dB 61 fps

The earlier rows in this PR (46.5/38.2/35.2 dB) used a different source, so the numbers aren't comparable. #2218's 8-bit encode set (30/30) ran on the same kernel.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the Main 10 work and the PSNR table. The KUnit case that checks the Start words against the 8-bit one is a nice touch.

One thing to change before merge. Main 10 is switched on by a per-variant flag described as "verified on this variant's hardware":

  • drivers/media/platform/apple/ave/ave.h:252-256 (counted_main10)
  • ave-drv.c:197
  • ave-sess.c:197-201
  • ave-v4l2.c:89-90

We select behaviour by a hardware or firmware property, not by the list of machines it was tested on. Your own reasoning is about the counted (26A428) firmware layout: its Start maps every bit-depth word. T6050 runs that same layout. So could ave_main10_supported() and the session check key on layout->counted instead? If T6050's encoder really differs, a comment citing the difference would do. counted_any_rate from #2218 follows the same pattern and could get the same treatment.

We can run AVE no-regression rows on the encoders we have (A18 Pro, M4 Pro).

@m0d16l14n1
m0d16l14n1 force-pushed the j815/t8142-ave-main10 branch from 1738b10 to 7395b50 Compare November 20, 2026 22:53
@m0d16l14n1 m0d16l14n1 changed the title media: apple: ave: T8142: encode HEVC Main 10 (on #2218) media: apple: ave: 26A428: encode HEVC Main 10 (on #2218) Nov 20, 2026
@m0d16l14n1

m0d16l14n1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@RyanTheTide done. Both flags are gone, and both checks now key on the layout. New heads: #2218 9f9abda4, this PR 7395b502.

  • Main 10 (this PR, 7395b502): the session refusal is removed. ave_main10_supported() is now layout->counted || kind == AVE_LAYOUT_9003.
  • Rates and no-B sessions (media: apple: ave: 26A428: 60 fps and no-B sessions, B-picture flags #2218, 9f9abda4): the "only 30 fps with 3 B-frames is qualified" refusal is removed for the 26A428 layout as a whole, and counted_any_rate is dropped. One AppleAVE2 kext builds these commands for every firmware on the layout, so it's a layout property, as you said.
  • T6050: it now gets both, for 26A428 and for the 27.3 beta that maps to the same layout. Only the M5 has encoded with them so far. A J714s row would confirm it: one 60 fps session, one no-B session, and P010 → HEVC.
  • A18 Pro / M4 Pro rows: welcome as no-regression rows. Those chips are on the 9003 layout, so their path is unchanged.

Checks:

  • checkpatch --strict 0/0/0 on both reworked commits.
  • KUnit (ave/.kunitconfig, arm64 QEMU, LLVM): 45/45, including ave_26a428_hevc_main10.
  • W=1: no warnings in drivers/media/platform/apple/ave/.
  • On T8142 the admitted sessions are the same as before, so the J815 results in both PRs still hold.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, this resolves our point. Both checks now follow the layout: ave_main10_supported() is layout->counted || kind == AVE_LAYOUT_9003, and the "only 30 fps with 3 B-frames is qualified" refusal is gone for 26A428 as a whole (#2218 at 9f9abda). No variant flag is left.

We'll run no-regression rows on our A18 Pro and M4 Pro (9003 layout): 8-bit HEVC and H.264 encode, plus P010 to HEVC Main 10, base vs head, output compared byte for byte. A J714s row from someone with an M5 Pro would cover the newly reached T6050.

@m0d16l14n1

m0d16l14n1 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased on the new #2218. The commit message no longer describes the macOS driver's command building or its buffer sizing.

One consequence of the rebase: integration's 26B123 layout is counted with the same Start, so it gets Main 10 too. It has no row there yet.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the rebase and the reworded commit message. With 26B123 now counted, it gets Main 10 as well, so one P010 to Main 10 row on an M5 running the macOS 27.2 encoder firmware (J813 or J815) would cover it. Our A18 Pro and M4 Pro no-regression rows (8-bit HEVC and H.264, P010 to Main 10, base vs head, compared byte for byte) will run on 1fa8c98 and go here.

Assisted-by: LLM (Claude:Opus 5.5)

@m0d16l14n1
m0d16l14n1 force-pushed the j815/t8142-ave-main10 branch from 1fa8c98 to eb867da Compare November 22, 2026 03:21
@m0d16l14n1

m0d16l14n1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased on #2218's new head: eb867da2. #2218's three commits come first, and the Main 10 commit is unchanged. #1900 has merged, so it's out of the stack. AVE KUnit 48/48 and W=1 are clean at every commit.

@RyanTheTide noted on the Main 10 row for 26B123 (now counted): one P010 → Main 10 row on a J815 on the 27.2 encoder firmware is owed on this head.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of eb867da (the Main 10 commit on top of #2218): no blockers.

The earlier point stays resolved: ave_main10_supported() is layout->counted || kind == AVE_LAYOUT_9003 (drivers/media/platform/apple/ave/ave-v4l2.c:85-89) and the session refusal is gone (ave-sess.c:196), with no per-variant flag left. The commit carries only the author's Signed-off-by.

A correction to our last comment: the 26B123 layout is the one ave_layout_for_crc() picks for the M4 (T8132) and M3 (T8122) 27.2 builds (ave-layout.c:1009-1011); the M5's 27.2 build is on 26A428 (ave-layout.c:1019). So with this commit Main 10 newly reaches J713 and J615. Because ave_main10_supported() also picks the new context's default coded format (ave-v4l2.c:171) and the profile menu (ave-v4l2.c:635), M3/M4 contexts now start on HEVC as on 9003. That's the intended behaviour, but GStreamer's H.264 path depends on it.

Optional: ave_26a428_hevc_main10 could loop over ave_layout_26b123 as well; it shares the Start through the same field macro, so the case costs nothing more.

Rows:

  • J815 on eb867da (owed by the author): the three P010 -> HEVC Main 10 encodes from the table.
  • We'll run J713 and J615 on eb867da: P010 -> HEVC Main 10 (decode and PSNR against the source) and a GStreamer v4l2h264enc encode to check the HEVC default. We'll also run our A18 Pro and M4 Pro (9003) no-regression rows: 8-bit HEVC and H.264, P010 -> Main 10, base vs head, byte for byte.

Assisted-by: LLM (Claude:Opus 5.5)

@m0d16l14n1
m0d16l14n1 force-pushed the j815/t8142-ave-main10 branch from eb867da to 103d274 Compare November 22, 2026 05:29
@m0d16l14n1

m0d16l14n1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks for the correction: 26B123 is the M3/M4 27.2 layout, and the M5's 27.2 build stays on 26A428. The commit message already says so, and it notes that M3/M4 contexts now start on HEVC as on 9003, so I've left it as is. Your J713/J615 GStreamer v4l2h264enc row is the right check for that default.

Optional point done in 103d2744: ave_26a428_hevc_main10 now loops over ave_layout_26a428 and ave_layout_26b123, with the layout in each message, and the commit message says the case covers both. The test is the only change. The AVE KUnit suite passes 48/48 on arm64 QEMU, and checkpatch --strict is clean.

Still owed by me: the J815 row on this head, the three P010 → HEVC Main 10 encodes from the table.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-PR checklist review at head 103d2744ca5b (stacked on #2218 at 0b40dfa119be).

Code & Correctness

0 code, policy, attribution, naming, or CI blockers found across the full 4-commit diff (3 commits from #2218 + the Main 10 commit 103d2744):

  • Main 10 enablement (103d2744): ave_main10_supported() (ave-v4l2.c) cleanly keys on layout capability (ave->layout->counted || ave->layout->kind == AVE_LAYOUT_9003) with the counted refusal removed in ave_sess_params() (ave-sess.c) and no per-chip/variant flags. Verified against ave-layout.c and ave-writer.c: both ave_layout_26a428 and ave_layout_26b123 map every bit-depth-dependent Start field (flag_8bit, geometry_depth, min_qp/min_qp2, bit_depth, hevc_profile_{a,b}, hevc_compat_{a,b}, hevc_8bit_{a,b}, hevc_depth_{luma,chroma}). The ave_26a428_hevc_main10 KUnit case covers both ave_layout_26a428 and ave_layout_26b123.
  • Stacked #2218 commits (1b9d7bbc, dc863249, 0b40dfa1): The Annex-B/RBSP B-frame slice scanner (ave_rbsp_*, ave_hevc_pps_extra_bits, ave_slice_is_b, ave_au_is_b, ave_au_bframe) enforces buffer/shift bounds (zeros > 31, sizeof(r->b) == 24, room >= (hevc ? 3 : 2)), matches H.264 Table 7-6 and H.265 §§7.3.2.3.1 & 7.3.6.1, clears s->bframe before error returns in ave_sess_output(), and scans key frames to track PPS num_extra_slice_header_bits. The fps_int_copy and low_delay fields are cleanly parameterized in AVE_LAYOUT_26A428_FIELDS with ave_26b123_layout verifying both remain 0 on 26B123.

Pre-PR Checklist (§1–§6)

  • §1 No model gating: Pass (keyed on layout properties, no chip/board gates).
  • §2 Production-ready, no hacks: Pass.
  • §3 Safety: Pass.
  • §4 Clean-room & attribution: Pass. All 4 commits carry human author/committer (Nick <[email protected]>) and human Signed-off-by: only, with zero AI trailers; PR body discloses agent assistance. Clean-room verified (rests on own captures/traces and KUnit tests).
  • §5 Evidence (Holding): host-tests CI is green (COMPLETED/SUCCESS), but live-head (103d2744) hardware proof is still pending:
    1. J815 (M5, 26A428): the three P010 -> HEVC Main 10 encodes + regression run (0 SELinux denials, 0 failed units, 0 new kernel errors) on head 103d2744.
    2. Newly reached 26B123 (M3 J615 / M4 J713): P010 -> HEVC Main 10 encode + GStreamer v4l2h264enc check confirming the new default HEVC coded format does not regress H.264 pipelines.
    3. 9003 no-regression rows (A18 Pro / M4 Pro) and optionally T6050 (J714s) for 26A428.
  • §6 Naming: Pass.

Holding approval only for the §5 live-head hardware rows above (and for base PR #2218 to merge first).

Assisted-by: LLM (Gemini 4 Neon)

@github-actions github-actions Bot added area:media Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
The firmware reorders the pictures of a B-frame session itself, so the
driver does not know a coded picture's type when it hands the buffer
out, and every picture that is not a key frame was flagged as a P frame.
Read the slice type of the access unit's first slice instead: a few bytes
of its slice header, with emulation-prevention bytes removed. HEVC needs
the PPS's num_extra_slice_header_bits to reach slice_type, so the session
remembers it from the last PPS it saw. Key frames are scanned too: they
carry the parameter sets. Anything the reader does not expect leaves the
picture flagged as a P frame, as before, and so does a buffer that comes
back with an error: the flag is cleared before anything else is read. A
KUnit case feeds a PPS with two extra bits, then a B slice that reads as I
without them.

The reader, built in user space, agrees with ffprobe's picture types on
every access unit of x264 (two slices per picture) and x265 streams with
3 B-frames. On the MacBook Air 15" M5 (J815), with ffmpeg's v4l2m2m
encoders and -bf 3, the buffers flagged B match the B pictures in the
streams exactly: 27 and 30 of 60 (H.264), 43 and 44 of 60 (HEVC).

Signed-off-by: Nick <[email protected]>
… low-delay word

macOS 27.2.1 on the M5 (T8142) writes the integer frame rate a second time
at Start +0x320c (60 at 60 fps), and for an HEVC session without B-frames
3 at Process +0xce4, the same low-delay word the 9003 layout
(ave_layout_9003_78_0) has at +0xcf8. Write both on the 26A428 layout.

The 26B123 layout shares 26A428's fields through one macro, which now
takes the two offsets. 26B123 passes 0 for both, so it writes neither:
its 60 fps and no-B sessions were run without them, and nothing has
traced its commands at those settings.

At 30 fps the second rate is the 0x1e the 26A428 Start ledger already
holds, and the low-delay word only applies to HEVC without B-frames,
which this layout does not run yet, so qualified sessions on every chip
send the same commands as before. The 26B123 KUnit case still checks
that the two layouts agree on every other field.

Signed-off-by: Nick <[email protected]>
…rames

The 26A428 layout runs only 30 fps sessions with B-frames (or H.264
Baseline and intra-only ones): those are the ones its command ledger was
qualified with.

We traced the Start and Process commands macOS 27.2.1 sends on the M5
(T8142) for 60 fps sessions and sessions without B-frames, and compared
them with what the driver sends for the same settings. With the two
words the previous commit adds, they match, apart from words that also
differ on a qualified 30 fps session with B-frames. Set any_gop on the
layout, as the 26B123 layout has it, so the refusal no longer applies
to it.

The flag is on the layout, so the M5 Pro and Max (T6050) firmware on
the same layout gets it too. Only the M5 has encoded with it so far.

Tested on the MacBook Air 15" M5 (J815), firmware 26B123 (the macOS 27.2
stub's, on the 26A428 layout), on two boots:
30 encode cases (H.264 Baseline/Main/High and HEVC Main; 30 and 60 fps;
with and without B-frames; VBR and CBR; 640x360 to 2560x1440), every
stream decoding to the expected frame count, PSNR 27-42 dB against the
source.

Signed-off-by: Nick <[email protected]>
The counted (26A428) layout refused HEVC Main 10, so on the M5 S_FMT
turned P010 into NV12 and a Main 10 profile failed at STREAMON. The
layout's Start maps every word the 9003 Main 10 capture changes with bit
depth: the 8-bit flag (0x35e8), the QP floors, the bit depth (0x37c0),
both profile/compat groups and the SPS luma/chroma depth. A KUnit case
builds a Main 10 Start on 26A428 and on 26B123 and checks those words
against the 8-bit one. The encodes below ran with the driver's existing
10-bit DPB and coded buffer sizes.

Lift the refusal for the layout, and list P010 for HEVC with Main 10 in
the profile menu there. Whether Main 10 can be encoded follows from what
the layout's Start maps, not from the chip, so it goes for every firmware
on the 26A428 layout; only the M5 (T8142) has encoded with it so far, and
the M5 Pro and Max (T6050) use the same layout. The 26B123 layout (the M3
and M4 with macOS 27.2) has the same Start, so it gets Main 10 too, with
no Main 10 row there yet. As on 9003, a new context then starts on
HEVC, so a client probing the raw formats first sees P010; clients that
set the coded format are unaffected.

Tested on a MacBook Air 15" M5 (J815, macOS 27.2 26B123 firmware):
v4l2-ctl P010 -> HEVC at 30 fps with B-frames, the decoded stream
compared with the input:
- 1280x720, 30 frames: Main 10, 4:2:0 10-bit, PSNR 46.5 dB, 269 fps;
- 1920x1080, 120 frames: PSNR 38.2 dB, 243 fps (86 B pictures);
- 3840x2160, 60 frames: PSNR 35.2 dB, 65 fps;
and no DART faults or timeouts. NV12 to HEVC Main (41.7 dB) and H.264
High (40.8 dB) at 1080p in the same run are unchanged.

Signed-off-by: Nick <[email protected]>
@m0d16l14n1
m0d16l14n1 force-pushed the j815/t8142-ave-main10 branch from 103d274 to 8613fb3 Compare November 25, 2026 03:45
@m0d16l14n1
m0d16l14n1 requested a review from a team as a code owner November 25, 2026 03:45
@m0d16l14n1
m0d16l14n1 requested a review from Acelogic November 25, 2026 03:45
@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 8613fb37: not ready yet

Check Detail
CI at head ok 3 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 8613fb37
Conflicts ok none
PR text ok Risk: two-way · . AVE HEVC encode on 26A428 (M5, M5 Pro/Max) and 26B123 (M3/M4 27.2): P010 appears in their format list and a new context starts on HEVC, as on 9003. The 9003 chips take the same path as before.

Areas: area:media

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 25, 2026
@m0d16l14n1

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr updated to 8613fb37d28b, on #2218's rebased commits.

J815 row at this head (in the body): P010 → HEVC Main 10 with 3 B-frames, every stream Main 10, yuv420p10le. 720p 37.3 dB, 1080p 32.8 dB, 2160p 34.5 dB, on a high-motion clip at 12 Mb/s. Regression at boot 0/0/0.

Still owed: 26B123 (M3/M4) Main 10 and the GStreamer H.264 check, plus the 9003 no-regression rows.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Verdict: FINISH, then merge at 8613fb37d28b

Blockers: none in the code. Dj's checklist review found no code, policy or gating blockers: Main 10 is keyed on the layout (counted or 9003), not the chip. The new head only rebases onto #2218, which has merged into main now. GitHub should drop its three commits from this PR on the next update, and a normal merge of main will do that.

Still needed: the rows your Not yet lists. We'll run them in our lab: 26B123 Main 10 encode and the GStreamer v4l2h264enc check on J713 (M4 Air), and a 9003 no-regression encode on J616s (M4 Pro) or the Neo (A18 Pro). The optional T6050 row stays with whoever has a J714s.

@RyanTheTide

Copy link
Copy Markdown
Contributor

8613fb3 J615 (M3 Air 15", T8122, macOS 27.2 26B123 counted layout) + J616s (M4 Pro, 9003) + Neo (J700, A18 Pro, 9003) PASS: batched on main 7f00dc6 (0 merge-tree diffs), default cmdline; J615 26B123 exposes P010 (vs NV12-only on stock fleet85) and encodes 60-frame HEVC Main 10 (yuv420p10le, 42 B / 15 P / 3 I) via v4l2-ctl at 1280x720 (209.9 fps, avg PSNR 39.92 dB, Y 41.29 dB) and 1920x1080 (143.6 fps, Y 41.14 dB), plus NV12 H.264/HEVC 60/60 and GStreamer v4l2h264enc 1080p 60/60; J616s and Neo 9003 no-regression H.264/HEVC/P010 (191.2 / 260.2 fps, Main 10 yuv420p10le 60/60) + GStreamer v4l2h264enc 1080p 60/60 ok; 0 AVE/DART errors, 0 failed units, Enforcing, 0 new AVC, 0 new kernel errors; stock defaults restored.

RyanTheTide
RyanTheTide previously approved these changes Nov 26, 2026

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 8613fb37d28b. The rows from your Not yet are in: 26B123 Main 10 on J615 (M3 Air), and 9003 no-regression on J616s (M4 Pro) and the Neo (A18 Pro). Independent software decode verified the saved streams at 60/60 each, including HEVC Main 10 yuv420p10le and GStreamer H.264. Dj's checklist review found no code blockers.

@m0d16l14n1
m0d16l14n1 dismissed RyanTheTide’s stale review November 26, 2026 06:56

The merge-base changed after approval.

@RyanTheTide
RyanTheTide merged commit 056740f into aurora-silicon:main Nov 26, 2026
7 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merged into main. Thank you! It merged on the hardware rows at this head and a non-author review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:media Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants