Skip to content

Fix dynamic slice adjustment for frames with extreme aspect ratios#3960

Open
sprangerik wants to merge 3 commits into
cisco:masterfrom
sprangerik:fix-dynamic-slicing-wide-frames
Open

Fix dynamic slice adjustment for frames with extreme aspect ratios#3960
sprangerik wants to merge 3 commits into
cisco:masterfrom
sprangerik:fix-dynamic-slicing-wide-frames

Conversation

@sprangerik

Copy link
Copy Markdown
Contributor

When rate control is disabled (RC_OFF_MODE), dynamic slice adjustment
in DynamicAdjustSlicing() defaults the minimum macroblock requirement per
slice (iMinimalMbNum) to the frame's macroblock width (1 row per slice).
For frames with extreme aspect ratios (such as very wide resolutions),
requiring 1 macroblock row per slice across multiple slices can exceed the
total number of macroblocks in the frame.

This change ensures robust macroblock distribution and load balancing by:

  • Falling back iMinimalMbNum to 1 macroblock per slice when row-based
    heuristics exceed frame capacity in RC_OFF_MODE.
  • Skipping adjustment and logging a warning when the requested number of
    slices equals or exceeds the total macroblocks in the frame.
  • Adding a capacity guard in GomValidCheckSliceMbNum() for rate-controlled
    encoding modes.
  • Adding a unit test (DynamicAdjustSlicingExtremeAspectRatio) to verify
    dynamic slice adjustment and load balancing on wide aspect ratio frames.

@sprangerik sprangerik force-pushed the fix-dynamic-slicing-wide-frames branch from dd49137 to c11d3bd Compare July 6, 2026 15:56
When rate control is disabled (RC_OFF_MODE), dynamic slice adjustment
in DynamicAdjustSlicing() defaults the minimum macroblock requirement per
slice (iMinimalMbNum) to the frame's macroblock width (1 row per slice).
For frames with extreme aspect ratios (such as very wide resolutions),
requiring 1 macroblock row per slice across multiple slices can exceed the
total number of macroblocks in the frame.

This change ensures robust macroblock distribution and load balancing by:
- Falling back iMinimalMbNum to 1 macroblock per slice when row-based
  heuristics exceed frame capacity in RC_OFF_MODE.
- Skipping adjustment and logging a warning when the requested number of
  slices equals or exceeds the total macroblocks in the frame.
- Adding a capacity guard in GomValidCheckSliceMbNum() for rate-controlled
  encoding modes.
- Adding a unit test (DynamicAdjustSlicingExtremeAspectRatio) to verify
  dynamic slice adjustment and load balancing on wide aspect ratio frames.
@sprangerik sprangerik force-pushed the fix-dynamic-slicing-wide-frames branch from c11d3bd to 4e9ac95 Compare July 9, 2026 11:23
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.

1 participant