Skip to content

feat(video,platform): declare explicit capture pixel formats - #5568

Open
luanweslley77 wants to merge 3 commits into
LizardByte:masterfrom
luanweslley77:feat/explicit-capture-pixel-format
Open

feat(video,platform): declare explicit capture pixel formats#5568
luanweslley77 wants to merge 3 commits into
LizardByte:masterfrom
luanweslley77:feat/explicit-capture-pixel-format

Conversation

@luanweslley77

@luanweslley77 luanweslley77 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

Capture backends now declare the negotiated pixel format on platf::img_t (pix_fmt_e pixel_format), and the RAM-path consumers (software encoder via libswscale, VAAPI/CUDA RAM) respect it instead of guessing from pixel_pitch. This continues the direction of #5495, which made the pitch information explicit.

With this, 10-bit HDR captures (PipeWire ARGB_2101010/ABGR_2101010, KMS BGRA1010102/RGBA1010102) reach the software encoder and the VAAPI/CUDA RAM converters correctly instead of being misread as 8-bit BGR0 with wrong colors. It also unblocks software HEVC Main10, which the encoder already advertises (AV_PIX_FMT_YUV420P10) but could never receive. Declared formats that a converter cannot represent now fail loudly instead of producing corrupt frames. The 10-bit shift formats are mapped unconditionally and therefore require the FFmpeg patch from build-deps #762, which the last commit pins in third-party/build-deps.

The last commit bumps third-party/build-deps to include the FFmpeg patch that registers BGRA1010102/RGBA1010102 (LizardByte/build-deps PR: LizardByte/build-deps#762). Without it, the branch still works but falls back to the previous behavior for those two formats.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes to affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

Add pix_fmt_e pixel_format to platf::img_t and make all capture
backends declare the negotiated format. The software encoder now
prefers the declared format and falls back to the pixel_pitch
heuristic only for unknown. VAAPI/CUDA RAM paths fail loudly for
formats they cannot represent. Includes the 2 zero-cost 10-bit
identity mappings (abgr/argb2101010 -> X2BGR10LE/X2RGB10LE) and
the 2 shift-formats (bgra/rgba1010102) mapped unconditionally via
native libswscale support, which the bundled build-deps FFmpeg
provides. Sync cuda.cu duplicate img_t and fix kmsgrab cursor to
bgra, handle P010 plane and fail loudly for unsupported declared
formats. Advertise NV12 on MemPtr for 8/8 capture.
Exercise declared BGR0/NV12/BGRA/xbgr2101010, the 2 identity 10-bit
formats and the 2 shift-formats with padded strides, plus FromPixFmt
and IsBgrCaptureFormat full matrices. A declared format with no
capture mapping must fail loudly.
Bump third-party/build-deps a9a9277 -> aabd22d (fix/ffmpeg-patch-fallback
rebased onto upstream/master 4d864e1).

Includes in build-deps:
- feat(ffmpeg): add BGRA1010102/RGBA1010102 pixel formats for 10-bit
  HDR PipeWire captures (SPA ARGB_210LE/ABGR_210LE) on MemPtr
- build(ffmpeg): wire libavutil patches into the shared patch list
  (new BUILD_FFMPEG_LIBAVUTIL_PATCHES option)
@luanweslley77
luanweslley77 force-pushed the feat/explicit-capture-pixel-format branch from 9e6fe0f to 4f25ed1 Compare August 29, 2026 03:36
@sonarqubecloud

Copy link
Copy Markdown

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