Skip to content

Speed up the TCQ q1 decide in the NEON st8 loop and the q1 rate C code - #5493

Merged
urvangjoshi merged 4 commits into
AOMediaCodec:av2-encfrom
jjustiss-apple:jjustiss/tcq-q1-neon
Oct 15, 2026
Merged

urvangjoshi merged 4 commits into
AOMediaCodec:av2-encfrom
jjustiss-apple:jjustiss/tcq-q1-neon

Conversation

@jjustiss-apple

@jjustiss-apple jjustiss-apple commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Make the q1 state decision in the NEON st8 loop branchless (compare, blend
and store in NEON registers). The old per-state branches mispredict on real
content. av2_decide_states_q1_neon is a thin RTCD wrapper around the same
impl for unit testing, as in AVX2.

The C q1 rate functions read the packed cost tables directly instead of the
generic cost path.

CTC (RA, cpu-used 1, 33 frames, Apple Silicon):

Metric A4 A5
Encode time -1.6% -1.7%
BD-rate Y/Cb/Cr 0.000% 0.000%

@jjustiss-apple jjustiss-apple changed the title Add NEON for TCQ q1 decide_states, optimize q1 rate C paths Add NEON for TCQ q1 decide_states, optimize q1 rate C code Oct 5, 2026
@jjustiss-apple

Copy link
Copy Markdown
Contributor Author

This PR depends on #5489 to land first as that PR creates trellis_quant_neon.c

@jianj-g

jianj-g commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

there'll be merge conflict with #5489 right? Can you merge that and resolve conflicts before I review? Thanks.

@jjustiss-apple

Copy link
Copy Markdown
Contributor Author

there'll be merge conflict with #5489 right? Can you merge that and resolve conflicts before I review? Thanks.

Yes, there'll definitely be merge conflicts. I'll ping you once the merge is clean and the PR is ready for review.

@jjustiss-apple
jjustiss-apple marked this pull request as draft October 8, 2026 16:11
@jjustiss-apple
jjustiss-apple marked this pull request as ready for review October 9, 2026 16:40
@jjustiss-apple

Copy link
Copy Markdown
Contributor Author

@jianj-g This one is rebased and ready for review

Comment thread av2/encoder/arm/neon/trellis_quant_neon.c
Comment thread av2/encoder/arm/neon/trellis_quant_neon.c Outdated
@jjustiss-apple jjustiss-apple changed the title Add NEON for TCQ q1 decide_states, optimize q1 rate C code Speed up the TCQ q1 decide in the NEON st8 loop and the q1 rate C code Oct 14, 2026
@urvangjoshi
urvangjoshi merged commit d8a9065 into AOMediaCodec:av2-enc Oct 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants