From e470f8986e7d544c7ccf526e987b9f869f0b5904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 27 Sep 2026 21:32:12 +0200 Subject: [PATCH] chmap_avchannel: remove mp_chmap_to_av_layout_custom() No longer used, might be restored later. --- audio/chmap_avchannel.c | 55 ----------------------------------------- audio/chmap_avchannel.h | 6 ----- 2 files changed, 61 deletions(-) diff --git a/audio/chmap_avchannel.c b/audio/chmap_avchannel.c index 20b78c1428..ec961de422 100644 --- a/audio/chmap_avchannel.c +++ b/audio/chmap_avchannel.c @@ -16,8 +16,6 @@ */ #include -#include -#include #include "chmap.h" #include "chmap_avchannel.h" @@ -51,56 +49,3 @@ void mp_chmap_to_av_layout(AVChannelLayout *dst, const struct mp_chmap *src) av_channel_layout_from_mask(dst, mp_chmap_to_lavc(src)); } } - -static int custom_init(AVChannelLayout *dst, int nb_channels) -{ -#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 37, 100) - return av_channel_layout_custom_init(dst, nb_channels); -#else - AVChannelCustom *map = av_calloc(nb_channels, sizeof(*map)); - if (!map) - return AVERROR(ENOMEM); - dst->order = AV_CHANNEL_ORDER_CUSTOM; - dst->nb_channels = nb_channels; - dst->u.map = map; - return 0; -#endif -} - -void mp_chmap_to_av_layout_custom(AVChannelLayout *dst, - const struct mp_chmap *src) -{ - *dst = (AVChannelLayout){0}; - - if (mp_chmap_is_unknown(src) || src->num <= 0) { - dst->order = AV_CHANNEL_ORDER_UNSPEC; - dst->nb_channels = src->num; - return; - } - - // A map in canonical (libavutil) order is exactly a native layout, which - // every libswresample version can remix. A custom order is only needed to - // preserve a non-canonical order or NA channels. - if (mp_chmap_is_lavc(src)) { - av_channel_layout_from_mask(dst, mp_chmap_to_lavc(src)); - return; - } - - if (custom_init(dst, src->num) < 0) { - dst->order = AV_CHANNEL_ORDER_UNSPEC; - dst->nb_channels = src->num; - return; - } - - // mp_speaker_id values < 64 match the AVChannel enum directly. NA maps to - // AV_CHAN_UNUSED. Anything else is unknown. - for (int n = 0; n < src->num; n++) { - if (src->speaker[n] == MP_SPEAKER_ID_NA) { - dst->u.map[n].id = AV_CHAN_UNUSED; - } else if (src->speaker[n] < 64) { - dst->u.map[n].id = src->speaker[n]; - } else { - dst->u.map[n].id = AV_CHAN_UNKNOWN; - } - } -} diff --git a/audio/chmap_avchannel.h b/audio/chmap_avchannel.h index 531d1084bf..84062c49d0 100644 --- a/audio/chmap_avchannel.h +++ b/audio/chmap_avchannel.h @@ -26,9 +26,3 @@ bool mp_chmap_from_av_layout(struct mp_chmap *dst, const AVChannelLayout *src); void mp_chmap_to_av_layout(AVChannelLayout *dst, const struct mp_chmap *src); - -// Like mp_chmap_to_av_layout(), but always exact. Emits a native layout when -// the map is in native order, otherwise a custom order layout that preserves -// the original channel order, with NA channels as AV_CHAN_UNUSED. -void mp_chmap_to_av_layout_custom(AVChannelLayout *dst, - const struct mp_chmap *src);