Skip to content

Fix asymmetric chroma plane stride handling in encoder preprocessing#3961

Open
sprangerik wants to merge 1 commit into
cisco:masterfrom
sprangerik:fix-asymmetric-chroma-strides
Open

Fix asymmetric chroma plane stride handling in encoder preprocessing#3961
sprangerik wants to merge 1 commit into
cisco:masterfrom
sprangerik:fix-asymmetric-chroma-strides

Conversation

@sprangerik

Copy link
Copy Markdown
Contributor

When preprocessing incoming I420 source frames, WelsMoveMemoryWrapper
previously read only the U chroma plane stride (iStride[1]) and used it as a
shared stride for copying both the U and V chroma planes. If an incoming
frame has distinct, asymmetric strides for the U and V chroma planes (for
example, when the U plane stride is larger than the V plane stride), copying
the V plane using the U plane's stride advances the source pointer incorrectly.

This change ensures correct memory advancement for each chroma plane by:

  • Modifying WelsMoveMemory_c to accept separate destination and source
    strides for the U and V chroma planes (iDstStrideU, iDstStrideV,
    iSrcStrideU, iSrcStrideV).
  • Updating WelsMoveMemoryWrapper to read and pass iStride[1] and iStride[2]
    separately from the input SSourcePicture.
  • Updating internal callers (DownsamplePadding and Padding) to pass their
    respective U and V line sizes cleanly.
  • Adding a unit test (CustomChromaPlaneStrides) to verify that distinct,
    asymmetric chroma plane strides are handled correctly.

@sprangerik sprangerik force-pushed the fix-asymmetric-chroma-strides branch from 3463bfa to 5a54974 Compare July 6, 2026 16:20
@sprangerik sprangerik force-pushed the fix-asymmetric-chroma-strides branch from 5a54974 to 03ef5d0 Compare July 9, 2026 11:32
When preprocessing incoming I420 source frames, WelsMoveMemoryWrapper
previously read only the U chroma plane stride (iStride[1]) and used it as a
shared stride for copying both the U and V chroma planes. If an incoming
frame has distinct, asymmetric strides for the U and V chroma planes (for
example, when the U plane stride is larger than the V plane stride), copying
the V plane using the U plane's stride advances the source pointer incorrectly.

This change ensures correct memory advancement for each chroma plane by:
- Modifying WelsMoveMemory_c to accept separate destination and source
  strides for the U and V chroma planes (iDstStrideU, iDstStrideV,
  iSrcStrideU, iSrcStrideV).
- Updating WelsMoveMemoryWrapper to read and pass iStride[1] and iStride[2]
  separately from the input SSourcePicture.
- Updating internal callers (DownsamplePadding and Padding) to pass their
  respective U and V line sizes cleanly.
- Adding a unit test (CustomChromaPlaneStrides) to verify that distinct,
  asymmetric chroma plane strides are handled correctly.
@sprangerik sprangerik force-pushed the fix-asymmetric-chroma-strides branch from 03ef5d0 to 57f4363 Compare July 9, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants