Add AVX SIMD implementations of video_orc_chroma_down_h2_u8 and video_orc_chroma_down_v2_u8 - #64
Draft
havardgraff with Copilot wants to merge 1 commit into
Draft
Add AVX SIMD implementations of video_orc_chroma_down_h2_u8 and video_orc_chroma_down_v2_u8#64havardgraff with Copilot wants to merge 1 commit into
havardgraff with Copilot wants to merge 1 commit into
Conversation
…_orc_chroma_down_v2_u8 Agent-Logs-Url: https://github.com/pexip/gstreamer/sessions/8be7ad13-5db3-442a-ad40-c034f5e0f7ef Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
havardgraff
July 17, 2026 10:12
View session
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.
With ORC disabled,
video_orc_chroma_down_h2_u8andvideo_orc_chroma_down_v2_u8fall back to scalar C loops processing one element at a time. This adds AVX1 vectorized paths that process 32 bytes per iteration.Approach
Both functions reduce to: average specific UV bytes, keep other bytes unchanged. This maps cleanly to
VPAVGB+VPBLENDVB— average everything, then blend to select only the chroma bytes from the averaged result.VPSHUFB) to align with the first pixel's UV position before averagingVPAVGBthe rows and blendImplementation details
VMOVDQU(256-bit load/store),VEXTRACTF128/VINSERTF128(lane split/merge),VPSHUFB,VPAVGB,VPBLENDVB(128-bit VEX-encoded SSE)__builtin_cpu_supports("avx"), falls back to original scalar code on non-AVX CPUsDISABLE_ORC && (__GNUC__ || __clang__) && (x86_64 || i386)Core pattern (v2 shown)
Verification
Tested against scalar reference across 15 sizes (0–1024), edge cases, and in-place operation — bitwise identical results.