Skip to content

media: apple: ave: 26A428: 60 fps and no-B sessions, B-picture flags - #2218

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

RyanTheTide merged 3 commits into
aurora-silicon:mainfrom
m0d16l14n1:j815/t8142-ave-rate

Conversation

@m0d16l14n1

@m0d16l14n1 m0d16l14n1 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What: on the 26A428 layout (M5, T8142), the AVE encoder runs other frame rates and sessions without B-frames, writes the two Start/Process words macOS 27.2.1 sends for them, and flags B pictures on the coded buffers (every chip).
Tested: J815 (MacBook Air 15" M5) at b3e6c51a4b5f: encode set 30/30 OK, all run natively (60 fps, no-B, CBR, H.264 Baseline/Main/High, HEVC Main, 360p-1440p). -bf 3: the buffers flagged B match ffprobe exactly (H.264 26/60, HEVC 42/60). Regression at boot: 0 SELinux denials (SELinux off), 0 failed units, 0 new kernel errors; 0 AVE/DART warnings during the encodes.
Risk: two-way door. AVE encode on 26A428 (M5, M5 Pro/Max); B flags on every chip. 26B123 (M3/M4 27.2) passes 0 for the two new words and is unchanged.
Not yet: nothing blocking. 60 fps CBR with B-frames on the high-motion clip overshoots its 6 Mb/s target by 35-42% (screen content: within 4%); that's rate control, not admission.

Details
  1. B pictures are flagged on the coded buffers. The firmware reorders B-frame sessions itself, so every non-key picture used to be flagged V4L2_BUF_FLAG_PFRAME. The driver reads the first slice's slice_type from the bitstream: a few bytes, emulation prevention removed, plus HEVC's num_extra_slice_header_bits from the last PPS. Key-frame access units are scanned too, since they carry the PPS. Anything unexpected falls back to P, as before. ave_sess_output() clears s->bframe with *keyframe at entry, so an errored CAPTURE buffer never carries a stale B. H.264 B is exactly slice_type 1 or 6.

  2. Two Start/Process words macOS 27.2.1 writes on the M5:

    • Start +0x320c, a second copy of the integer frame rate (60 at 60 fps);
    • Process +0xce4 = 3 for HEVC without B-frames (the 9003 layout, ave_layout_9003_78_0, has it at +0xcf8).

    At 30 fps the first is the 0x1e the 26A428 Start ledger already holds, and the second only applies to the sessions the next change admits. So 30 fps sessions with B-frames send the same commands as before.

  3. 26A428 runs other frame rates and sessions without B-frames (any_gop, as on 26B123), instead of the refusal being deleted, so a future counted layout without rows is still refused. Our traces of macOS 27.2.1's Start and Process commands for 60 fps and no-B sessions match what the driver sends, apart from words that also differ on a qualified 30 fps B-frame session.

T6050 shares the layout: DjDeveloperr's J714s row on bf6356a0 covers it (16/16 at 30 and 60 fps, with and without B, a failing pre-patch 60 fps control, 1080p30 byte-identical).

Changed on this head: rebased onto main (#1900 merged, so this is its three commits). The KUnit layout cases follow main's 26B123/T8112 changes. No AI attribution in the body or the commits.

Evidence

J815, macOS 27.2 stub (AVE firmware 26B123 on the 26A428 layout), this head merged with the other J815 PRs into one test kernel on main 2943fff. Encode set: codec-lab encode --quick, AVE and a software reference per case, PSNR/SSIM against the source.

case PSNR rate vs target speed
H.264 High 1080p 3/6/12 Mb/s, 3 B 27.5 / 29.0 / 31.4 dB +14 / +11 / +4 % 224-230 fps
H.264 High 1080p 6 Mb/s, no B 28.9 dB +3 % 232 fps
H.264 1080p60 CBR 6 Mb/s, no B / 3 B 27.2 / 28.3 dB +12 / +42 % 229-231 fps
H.264 1440p60 CBR 9 Mb/s, no B 28.2 dB +9 % 140 fps
H.264 Baseline / Main 1080p 6 Mb/s 28.4 / 28.9 dB +4 / +12 % 226-231 fps
HEVC Main 1080p 3/6/12 Mb/s, 3 B 28.6 / 30.7 / 32.9 dB +16 / +14 / +10 % 221-227 fps
HEVC Main 1080p 6 Mb/s, no B 30.1 dB +3 % 223 fps
HEVC 1080p60 CBR 6 Mb/s, no B / 3 B 28.0 / 29.3 dB +13 / +35 % 222 fps
HEVC 1440p60 CBR 9 Mb/s, no B 29.1 dB +6 % 133 fps
screen content, 1080p60 CBR (H.264, HEVC, no B / 3 B) 39.6-40.2 dB -2 to +4 % 222-230 fps

All 30 AVE cases OK; the table leaves out the 720p and 360p cases and the into-tree and screen VBR variants (28.1-41.5 dB). -bf 3 B flags: H.264 60 CAPTURE buffers, 26 flagged B, ffprobe 26 B pictures; HEVC 60, 42 flagged, ffprobe 42.

@m0d16l14n1 m0d16l14n1 changed the title media: apple: ave: T8142: 60 fps and no-B sessions, B-picture flags (on #1900) media: apple: ave: 26A428: 60 fps and no-B sessions, B-picture flags (on #1900) Nov 20, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

I checked the three new commits on top of #1900. fps_int_copy goes through ave_start_put32(), which skips offset 0, so layouts without the field are untouched (ave-writer.c:416-420, 787). .low_delay = 0xce4 is on the HEVC Process entry only and writes 0 for B-frame sessions, so 30 fps B sessions are unchanged. The slice-header walk follows the H.264/HEVC syntax correctly (first_slice flag, no_output_of_prior_pics for IRAP, PPS id, extra bits, slice_type). Lifting the 30 fps limit only touched the counted layout, which is 26A428 alone (ave-layout.c:293).

  1. drivers/media/platform/apple/ave/ave-sess.c:1497: s->bframe = !*keyframe && ave_au_is_b(...) means ave_au_is_b() never runs on a key-frame access unit. Those are the access units that carry the VPS/SPS/PPS (the parameter sets copied from the metadata at ave-sess.c:1458-1466 come with the IDR). So the PPS branch at ave-sess.c:1211 never sees a PPS, and sess->hevc_extra_bits stays 0 for the whole session. That matches the J815 streams only because their PPS has num_extra_slice_header_bits = 0; any non-zero value makes every HEVC B/P decision read the wrong bits. Scan for the PPS on every access unit, e.g. call ave_au_is_b() unconditionally and AND its result with !*keyframe, or learn the bits in ave_scan_nals().
  2. Trailers: 5eed1c6, 752e337 and 9f9abda carry Assisted-by: Claude Opus 5.5, and c878774 (from media: apple: ave: T8142: admit the macOS 27.2 (26B123) encoder firmware #1900) carries Co-Authored-By: Claude Opus 5.5. Commits should carry only the human Signed-off-by. The disclosure belongs on the PR body's last line, as Assisted-by: LLM (Claude:Opus 5.5) (the current last line lacks the LLM (...) form).

Also, the commit message of 9f9abda justifies the change by how the macOS encoder driver builds its commands internally ("one AppleAVE2 kext builds these commands for every firmware on the layout"). Please base the argument on our own traces instead: the Start/Process words captured on the M5 match across 30/60 fps and B/no-B sessions. Leave out statements about how Apple's binary works.

HW row: J815 on this head with item 1 fixed: the same 30-case set plus an HEVC -bf 3 run whose PPS has non-zero num_extra_slice_header_bits (or a KUnit case feeding such a PPS + B slice), with B flags matching ffprobe. A J714s (T6050) 60 fps and a no-B session would cover the layout-wide change. Both need 0 AVC, 0 failed units and 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@m0d16l14n1

m0d16l14n1 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@RyanTheTide both blockers are fixed.

  1. ave_au_bframe() now scans every access unit, key frames included, so the PPS's num_extra_slice_header_bits is learned from the IDR. A KUnit case, ave_hevc_bframe_extra_bits, feeds a PPS with 2 extra bits, then a B slice. Without the bits, that slice reads as I. AVE KUnit 48/48.
  2. Trailers: all four commits carry only my sign-off.

The rebase onto cc14570 met integration's any_gop (1d21390). The last commit now sets any_gop on 26A428 instead of deleting the refusal. Its message rests on our M5 traces: 60 fps and no-B sessions match apart from words that also differ on a qualified session. It makes no statement about how the macOS driver builds commands.

The two new words go through AVE_LAYOUT_26A428_FIELDS(rate_copy, hevc_low_delay). 26B123 passes 0, so the M3/M4 sessions are unchanged.

checkpatch flags the macro's two parameters as unused. Their uses are in other hunks of the same macro.

HW row (30-case set + HEVC -bf 3 with B flags vs ffprobe) to follow on the J815. A J714s row would cover T6050.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of bf6356a: No blockers.

Earlier points:

  1. Resolved. drivers/media/platform/apple/ave/ave-sess.c:1238 ave_au_bframe() runs ave_au_is_b() on every access unit and only then masks key frames, and ave-sess.c:1518 calls it, so the PPS's num_extra_slice_header_bits is learned from the IDR. I hand-decoded the bytes of the new KUnit case at ave-abi-test.c:1520: the PPS gives 2 extra bits, the IDR slice parses as I, and the TRAIL_R slice parses as B with the bits and as I without them, so the case exercises the path it claims to. hevc_extra_bits starts at 0 because the session is allocated zeroed.
  2. Resolved. All four commits carry only the author's Signed-off-by, and the PR body ends with the Assisted-by: LLM (...) line.
  3. Resolved. The commit message of bf6356a now argues from our own M5 command traces.

What changed since: the rebase onto the base's any_gop refusal. 26A428 now sets .any_gop = true (ave-layout.c:556) instead of dropping the check. The two new words go through AVE_LAYOUT_26A428_FIELDS(rate_copy, hevc_low_delay) (ave-layout.c:554), and 26B123 passes 0 so it writes neither. The 26B123 KUnit case masks only those two words before comparing the layouts. The 27.2 M5 build is chosen by TEXT CRC among builds of the same size (ave-fw.c ave_fw_find_build() with the CRC, falling back to the size-only match, which keeps an unknown CRC refused). I found no problems.

HW row: any_gop is on the layout, so the M5 Pro/Max firmware on 26A428 now runs 60 fps and no-B sessions as well, and only the M5 has encoded with it. A J714s (T6050) run of the 60 fps and no-B HEVC/H.264 cases from the 30-case set, with every stream decoding to the expected frame count, would cover that. The J815 30-case run in bf6356a should also report its regression line: 0 AVC denials, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

DjDeveloperr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

PASS on a 14-inch MacBook Pro (J714s, M5 Pro/T6050, G17S B1), kernel 7.3.0-m5-rows-prs, at b3e6c51a4b5fc1c394b2589fc7a63cf78b61ca0e.

Candidate 053c0549b09b7a48582d5dfbfeb1ddbb25af442d merged these unchanged heads onto main 15695c3ba53291e78bf62140598dbdffc7fb2b72 plus Clang fix 0050f580cc54892302f38e458e609d1b793010e0, which has since merged. The baseline was that same main plus the fix (f2b85419afafcfd6e6bc5ceeaa79e9ee557563a4).

The merged heads were #2906 f3ad1a8f362c, #3123 822a1dd7369c, #3116 064c3c65cd3e, #2949 0a4f6d6576a3, #2913 48b6d70dde9e, #2218 b3e6c51a4b5f and #2007 4738426f6c24.

AVE firmware 26A428 encoded the synthetic 1920×1080, 30 fps input through V4L2 on both arms. H.264 and HEVC each produced 60/60 frames on both arms. ffprobe counted 60 decoded frames and FFmpeg decode exited 0 for all four outputs. The bitstream checksums matched within each codec. Both arms logged 0 AVE errors and 0 DART faults during the encodes.

The command line matched the default. SELinux was disabled. tailscaled.service was the one failed unit on both boots and on the default. Each boot had 6 error-priority lines, all the known DCP clock-index message. After one deep cycle, there were 83 warning/error-priority lines on the baseline and 79 on the candidate, with zero added lines and zero kernel WARNING: reports. The known DCP clock-index message occurred 10 times on each arm through the wake.

Earlier J714s row

J714s (M5 Pro, T6050) Hardware Row — bf6356a0fb62 (26A428)

Tested exact PR head bf6356a0fb6252d1dd3449036b21c3985d443017 (stacked on #1900 1a4cbee1a2690558e1b947341e85331b98adeaa0, 0-byte patch diff) on J714s (M5 Pro, T6050) running macOS 27.0 (26A428) AVE firmware (apple-ave 2283100000.video-encoder: firmware build 26A428 (TEXT 0x154000 CRC 87279429, DATA 0x134000)), MTE enabled (arm64.nomte absent), SEP writes enabled.

  • Pre-patch control on same machine: 1080p60 H.264 (B=2) failed as expected without #2218, while 1080p30 H.264/HEVC (B=2) passed.
  • With #2218 (bf6356a0fb62): 16/16 PASS, every case encoded 60/60 frames and decoded cleanly via ffprobe -count_frames + ffmpeg -f null (dec_rc=0), with 0 DART faults, 0 AVE errors, 0 oops/WARN, 0 SELinux AVCs, 0 new failed units:
Case Codec / Path Res & FPS Frames Decoded Picture Types Size (B) MD5 (prefix)
gst_h264_1080p30_b2 GStreamer v4l2h264enc (B=2) 1080p30 60/60 ok I=2,P=58 1,008,266 15ec74768775ff5c
gst_hevc_1080p30_b2 GStreamer v4l2h265enc (B=2) 1080p30 60/60 ok B=42,I=3,P=15 1,082,100 830f3b57e0a590ee
gst_h264_1080p60_b2 GStreamer v4l2h264enc (B=2) 1080p60 60/60 ok I=2,P=58 523,771 8894d30a8af1dd37
gst_hevc_1080p60_b2 GStreamer v4l2h265enc (B=2) 1080p60 60/60 ok B=42,I=3,P=15 578,864 edb84b0fb46d8e20
gst_h264_1080p60_b0 GStreamer v4l2h264enc (no-B) 1080p60 60/60 ok I=2,P=58 523,771 8894d30a8af1dd37
gst_hevc_1080p60_b0 GStreamer v4l2h265enc (no-B) 1080p60 60/60 ok I=2,P=58 568,790 e1a434a06f9e2092
gst_h264_1080p30_b0 GStreamer v4l2h264enc (no-B) 1080p30 60/60 ok I=2,P=58 1,008,266 15ec74768775ff5c
gst_hevc_1080p30_b0 GStreamer v4l2h265enc (no-B) 1080p30 60/60 ok I=2,P=58 1,049,761 755379e15c6fb04b
gst_h264_default_30 Stock GStreamer v4l2h264enc 1080p30 60/60 ok I=2,P=58 1,008,266 15ec74768775ff5c
gst_hevc_default_30 Stock GStreamer v4l2h265enc 1080p30 60/60 ok B=42,I=3,P=15 1,082,100 830f3b57e0a590ee
gst_h264_default_60 Stock GStreamer v4l2h264enc 1080p60 60/60 ok I=2,P=58 523,771 8894d30a8af1dd37
gst_hevc_default_60 Stock GStreamer v4l2h265enc 1080p60 60/60 ok B=42,I=3,P=15 578,864 edb84b0fb46d8e20
ffmpeg_h264_1080p30 FFmpeg h264_v4l2m2m 1080p30 60/60 ok I=5,P=55 1,025,026 8302e98985b01537
ffmpeg_h264_1080p60 FFmpeg h264_v4l2m2m 1080p60 60/60 ok I=5,P=55 532,979 d2c523ec9e2cf948
ffmpeg_hevc_1080p30 FFmpeg hevc_v4l2m2m 1080p30 60/60 ok I=5,P=55 1,023,688 fd336e0e1e25f3c5
ffmpeg_hevc_1080p60 FFmpeg hevc_v4l2m2m 1080p60 60/60 ok I=5,P=55 557,631 e2230c0d03adcf81
  • Regression line: 1080p30 H.264 (1008266 B, 15ec74768775ff5c) and HEVC (1082100 B, 830f3b57e0a590ee) are byte-identical to baseline; GPU Vulkan liveness passed before and after.

@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.

Reviewed head bf6356a0fb6252d1dd3449036b21c3985d443017 against pre-pr-checklist.md.

Verdict: Request Changes (blockers remain before merge)

Blockers

  1. Stale s->bframe flag on ave_sess_output() error paths (drivers/media/platform/apple/ave/ave-sess.c:1451,1518, ave-v4l2.c:1148-1156):
    • ave_sess_output() clears *keyframe = false at entry, but does not clear s->bframe before its early error returns (-EFAULT, -EIO, ave_sess_decode_result(), -EPROTO), and ave_sess_prepare_slot() does not clear s->bframe on slot reuse.
    • In ave_deliver(), when ave_sess_output() returns an error (state = VB2_BUF_STATE_ERROR), dst->flags is still populated from s->bframe. Reusing a slot whose previous picture was a B-frame will stamp a stale V4L2_BUF_FLAG_BFRAME onto an errored CAPTURE buffer.
    • Fix: clear s->bframe = false alongside *keyframe = false at the top of ave_sess_output() (or pass bool *bframe as an out-parameter like key and drop bframe from struct ave_slot, since ave_deliver() is its only reader).
  2. Unmerged base PR #1900:
    • Commit 1 (1a4cbee1a2690558e1b947341e85331b98adeaa0) belongs to #1900, which is still OPEN (targeting integration/aurora) and still owes its J815 27.2 + 27.0 stub regression HW row. #1900 should be verified and merged first (or #2218 rebased after #1900 lands) so #2218 does not pull #1900 in ahead of its 27.0 regression check.
  3. J815 (T8142) hardware row on current head bf6356a0fb62 still owed:
    • The T6050 (26A428) coverage gap is now closed by the J714s 16/16 PASS row on exact head bf6356a0fb62 (#issuecomment-7068611954: pre-patch 1080p60 failure control, 30/60 fps H.264/HEVC with B and no-B, byte-identical 1080p30 baseline, 0 DART faults, 0 AVE errors, 0 oops/WARN, 0 SELinux AVCs, 0 new failed units).
    • However, as the PR body notes, the J815 run on the rebased head bf6356a0fb62 (30-case set + HEVC/H.264 -bf 3 verifying CAPTURE V4L2_BUF_FLAG_BFRAME against ffprobe, plus the regression line: 0 SELinux AVCs, 0 failed units, 0 new kernel errors) has not been posted yet.

Non-blocking nits

  • drivers/media/platform/apple/ave/ave-sess.c:1188: H.264 slice_type is only defined for 0..9 (1 and 6 are B slices); type == 1 || type == 6 is stricter than type >= 0 && type % 5 == 1 on malformed input.
  • Commit ff9e684544db message and PR body say the +0xcf8 low-delay word is on "the 6070 layout", whereas .low_delay = 0xcf8 is on ave_layout_9003_78_0 (ave-layout.c:265), not ave_layout_6070_11_1.

Verified clean

  • Bitstream parser & KUnit (ave_au_bframe, ave_hevc_bframe_extra_bits): Emulation-prevention removal (00 00 03), ue(v) leading-zero bound (> 31), HEVC PPS num_extra_slice_header_bits parsing (H.265 7.3.2.3.1), key-frame scanning for PPS learning, and slice header parsing (H.265 7.3.6.1 / H.264 7.3.3) all check out; hand-decoded the KUnit test vectors and confirmed they exercise the 2-extra-bit path as described.
  • Firmware probe & layout isolation (ave-fw.c, ave-layout.c, ave-writer.c): ave_fw_probe() fails closed on unknown or cross-chip CRCs; AVE_LAYOUT_26A428_FIELDS(0x320c, 0xce4) vs AVE_LAYOUT_26A428_FIELDS(0, 0) keeps 26B123 (M3/M4), 9003, and 6070 untouched, and 0x320c matches the 0x1e already in the 26A428 Start ledger at 30 fps.
  • Checklist rules 1–4: No board/model gates (firmware-ABI layout/CRC selection), default cmdline, no hacks, clean-room commit messages, human-only Signed-off-by: Nick <[email protected]> on all 4 commits, and PR body ends with Assisted-by: LLM (Claude:Opus 5.5).
  • CI: host-tests 1/1 green (note: repo kunit workflow is path-filtered and does not trigger on drivers/media/platform/apple/ave/**; author reports 48/48 AVE KUnit locally).

@m0d16l14n1 m0d16l14n1 changed the title media: apple: ave: 26A428: 60 fps and no-B sessions, B-picture flags (on #1900) media: apple: ave: 26A428: 60 fps and no-B sessions, B-picture flags Nov 22, 2026
@m0d16l14n1

m0d16l14n1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr thanks for the review, and for the J714s row.

  1. Stale s->bframe: fixed. ave_sess_output() clears s->bframe next to *keyframe at entry, so an errored CAPTURE buffer from a slot whose last picture was B is flagged P, as before.
  2. media: apple: ave: T8142: admit the macOS 27.2 (26B123) encoder firmware #1900: it has merged. The branch is rebased onto integration/aurora b241e35 and is now its three commits: 1b9d7bbc, dc863249, 0b40dfa1. The title no longer says "on media: apple: ave: T8142: admit the macOS 27.2 (26B123) encoder firmware #1900".
  3. J815 row: still owed on this head, as the description says.

Nits, both taken:

  • H.264 B is exactly slice_type == 1 || slice_type == 6.
  • The low-delay word: you're right, +0xcf8 is in ave_layout_9003_78_0. The commit message and the description now say "the 9003 layout".

Against bf6356a0, the code change is only those two lines in ave-sess.c (git range-diff: commit 3 is identical, commit 2 is message-only), so your J714s row's code path is unchanged.

Checks:

  • AVE KUnit 48/48 (arm64 QEMU, LLVM).
  • Every commit builds drivers/media/platform/apple/ave with W=1 and no warnings.
  • checkpatch --strict is clean apart from the known false positive on commit 2. It reads the macro's two parameters as unused because their uses are in another hunk.

#2547 is rebased on top.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 0b40dfa: no blockers.

Earlier points:

  • Resolved. ave_sess_output() now clears s->bframe together with *keyframe before its first early return (drivers/media/platform/apple/ave/ave-sess.c:1452), and ave_deliver() always calls it before reading the flag (ave-v4l2.c:1148-1156), so an errored CAPTURE buffer is flagged P, never a stale B.
  • Resolved. H.264 B is now exactly slice_type 1 or 6 (ave-sess.c:1188), and the commit message of dc86324 names the 9003 layout for the +0xcf8 word.
  • Still resolved from the earlier round: every access unit is scanned for the PPS (ave-sess.c:1519), and the commits carry only the author's Signed-off-by.

Against bf6356a the third commit is unchanged and the first two only differ by the above, so the J714s (T6050) row on bf6356a still covers the layout-wide 60 fps and no-B change.

HW row still owed: J815 on 0b40dfa, the 30-case set plus HEVC and H.264 -bf 3 with the B flags matching ffprobe, and the regression line (0 AVC denials, 0 failed units, 0 new kernel errors).

Assisted-by: LLM (Claude:Opus 5.5)

@github-actions github-actions Bot added area:media Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) merge-conflict Conflicts with the base branch (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at b3e6c51a: ready to merge

Check Detail
CI at head ok 3 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at b3e6c51a
Conflicts ok none
PR text ok Risk: two-way · . AVE encode on 26A428 (M5, M5 Pro/Max); B flags on every chip. 26B123 (M3/M4 27.2) passes 0 for the two new words and is unchanged.

Areas: area:media
Merge: gh pr merge 2218 --merge (Owners and Core through the bypass: add --admin).

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 b3e6c51a4b5f:

J815 rows at this head (in the body):

  • Encode set 30/30 OK, all run natively (60 fps, no-B, CBR, 360p-1440p, H.264 Baseline/Main/High, HEVC Main).
  • -bf 3 B flags match ffprobe exactly (H.264 26/60, HEVC 42/60).
  • Regression at boot 0/0/0; 0 AVE/DART warnings.

One observation, not a blocker: 60 fps CBR with B-frames overshoots its 6 Mb/s target by 35-42% on the high-motion clip (screen content: within 4%).

ludagoo added a commit to ludagoo/linux that referenced this pull request Nov 25, 2026
6070 firmware writes the parameter sets to a buffer of their own. On
a J475c (T6021) the SPS there had no VUI timing, and with B-frames off
no VUI at all, so a raw Annex B reader guessed 25 fps. When an SPS
from that buffer has no timing_info, rewrite it in the output buffer:
set timing in an existing VUI, or add a minimal one. The timing is the
client's timeperframe exactly, not the integer rate the firmware gets:
H.264 gets num_units_in_tick equal to the denominator and time_scale
twice the numerator, with fixed_frame_rate_flag, which is how H.264
codes a frame rate; HEVC gets vui_num_units_in_tick equal to the
denominator and vui_time_scale equal to the numerator. The rate is
taken in lowest terms, so 60/2 gives the bytes of 30/1, and 30000/1001
gives 1001 and 60000 (H.264) or 1001 and 30000 (HEVC). ffprobe on a
raw H.264 stream prints the field rate (60/1 at 30 fps) and an MP4 mux
reports 30/1.

When twice the numerator does not fit 32 bits, H.264 halves an even
denominator instead; with an odd one there is no exact form and the SPS
is left as written.

The rewrite is keyed on the stream, not on a SoC or firmware flag: an
SPS that already has timing is left alone, and so is one this walk
cannot follow (scaling lists, POC type 1, more than one HEVC
sub-layer, more than 256 bytes). Firmware that puts its parameter
sets in the coded buffer (9003, 26A428) is not touched.

The SPS is read with the RBSP reader of the T8142 slice-type probe
in aurora-silicon#2218 (struct ave_rbsp, ave_rbsp_init(),
ave_rbsp_bit(), ave_rbsp_ue()), with ave_rbsp_get() and
ave_rbsp_get_ue() added and the buffer raised to 256 bytes so a whole
SPS fits. Whichever of the two lands second drops its copy. The
rewrite's two scratch buffers (704 bytes) are allocated for the call
rather than kept on the stack; if that fails the SPS is left as written.

Signed-off-by: Lucas Goossen <[email protected]>

@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.

Code approved at b3e6c51a4b5f. The output parser clears the B-frame flag before it can return an error, and #1900 has landed. The J815 passed all 30 encodes and its flagged B frames matched ffprobe. Before merge, verify the existing J714s result carries forward to this build or record a second-generation encode.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merged into main. Thank you! It merged on the hardware row at this head and the approving review.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Post-merge J773g (M4 Mac mini, T8132 AVE, 27.2 firmware) row at b3e6c51a4b5f: PASS. The bitstreams are bit-exact with main's driver, and the B-picture flags are now correct.

How it was run: two guarded one-shots on the default cmdline.

Encodes: 60 frames of 1280×720 NV12 (testsrc2) through the apple-ave V4L2 node. B-frames set with video_b_frames 0 or 3.

stream bytes md5, main and candidate picture types capture flags, main capture flags, candidate
H.264, no B 1,020,007 b30e56ea… (identical) 2 I, 58 P 60/60 correct 60/60 correct
H.264, B=3 1,032,289 7a4eeb27… (identical) 3 I, 16 P, 41 B 41 B pictures flagged P-frame 60/60 correct
HEVC, no B 1,010,158 23cee0bd… (identical) 2 I, 58 P 60/60 correct 60/60 correct
HEVC, B=3 1,033,138 95200ee4… (identical) 3 I, 15 P, 42 B 42 B pictures flagged P-frame 60/60 correct

The picture types come from the coded stream. Each CAPTURE buffer's KEYFRAME, PFRAME or BFRAME flag was matched to its access unit by byte offset.

Health: 0 AVE or DART errors on either kernel, 0 failed units, and the same set of error-level kernel lines on both (0 new). No audio.

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) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants