Skip to content

swresample: pass input layout in mpv's order via custom channel order - #18034

Merged
kasper93 merged 2 commits into
mpv-player:masterfrom
kasper93:swr
Jun 1, 2026
Merged

swresample: pass input layout in mpv's order via custom channel order#18034
kasper93 merged 2 commits into
mpv-player:masterfrom
kasper93:swr

Conversation

@kasper93

Copy link
Copy Markdown
Member

No description provided.

Comment thread audio/chmap_avchannel.c Outdated
@kasper93
kasper93 force-pushed the swr branch 2 times, most recently from 875e2b5 to 0beae6e Compare May 28, 2026 16:20

@Dudemanguy Dudemanguy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jeeb jeeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Cleans up things nicely. Doing custom layouts specifically even when they possibly match an FFmpeg standard layout is a bit specific, but I don't really see it as a too big negative. We will anyways have to handle custom channel layouts in chmap_avchannel at some point.

kasper93 added 2 commits June 1, 2026 16:50
Since 9ef614d this helper has been a no-op. fudge_layout_conversion()
returned the modified uint64_t channel-layout bitmask, but the new
AVChannelLayout path builds out_layout from the unfudged out_lavc and
feeds that to swr.

Even when it was wired up, libswresample handles the BL/BR <-> SL/SR
mapping if needed. SDL/SDR is not currently handled, but I would rather
patch the swr/rematrix.c for those too, instead of having custom glue
here.

Note that SDL/SDR are not that common in-practice.
Drop the swr_set_channel_mapping() + transpose_order() + reorder_in[]
plumbing. Instead, build the swr input channel layout directly from the
mpv chmap as AV_CHANNEL_ORDER_CUSTOM, so the labels in the layout already
match the positions of the channels in the input data.

For all unknown map, we return all UNSPEC, so the swr expands to default
layout for this channel number.
@kasper93
kasper93 merged commit f5d4d9b into mpv-player:master Jun 1, 2026
32 checks passed
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.

3 participants