From patchwork Mon Jan 29 23:27:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 45894 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:8786:b0:199:de12:6fa6 with SMTP id ph6csp1840010pzb; Mon, 29 Jan 2024 15:28:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0C1Xa6r7BsiT1PnvAhBhkJJT2yaqY27XPiyQGA6lziHNNd//+ifMWlrluin1di6BZZXPp X-Received: by 2002:a50:fc10:0:b0:55f:2854:c55f with SMTP id i16-20020a50fc10000000b0055f2854c55fmr1235132edr.0.1706570909196; Mon, 29 Jan 2024 15:28:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706570909; cv=none; d=google.com; s=arc-20160816; b=Ce9R+LgQHQE24/F+I7VP37mhmJrm7Zl9pRvBs02DnK/inaVZxPtEASCD6OgbDEewqr JWsC0f5ue5kNcR44QazXkHeuWGhfm/QgUQPpAdXCqi/qG4FjzY2c+mE6/Pu1VZe5jpHB gmqbkfJHy4/tQeoH2YsOsLZTopahGW6IH6EWnG/cF2uRqJjVopZT7bBibKnKHhBQJLvZ w/UYGBtGAaccJn2Vq+TRhS6uz5axXYu2Nr5ZoYxu8/fClfh2Ru7kZqsvYdLA5Xq0/oLn +aEK4UyiDPTWKK+LBC4ZhzLmTNWqF7n05QR5ivAhfYvQL1Srcvh0CASQePQ2wlXkhJ2Q IKjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=cAbnd4wLhktmntsP4+dqOXGk24DDoCxd8qfn78kbVKw=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=xfSKdRi1ltRTpTELG9pVT/0XuvawfC0OKZ4nfBiWU6gEoWI5Fuu+R2bMLpC2UOjASJ jaeSxGNg4in/V4GIAjKwn9Keh8szUbt//GG87o+GKoZaqFZUCd7KO//V7+B9dE1F4P4C S1t44MSxZwEkXd7jw1C+4ERkbTE184agGUhgB5XchOf+jZ6WKQoG2NC1htbc73cS6bhx dfJZp3nUEtkWxd7Fah3em+qAjzzKErRUlMomDQtJ4h4F2ckQb4zdELMdg68RCx70QDfN w2kHA9nm0kFRah+zkh76vSUD//WDvDik2enoDUJG6ShsI6hCDvXpWifnvEfNEsFsfHTn stKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eo8-20020a056402530800b0055400f1f188si3972027edb.41.2024.01.29.15.28.28; Mon, 29 Jan 2024 15:28:29 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A42268D289; Tue, 30 Jan 2024 01:28:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 75B2968D28D for ; Tue, 30 Jan 2024 01:28:08 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 43318E9CAA; Tue, 30 Jan 2024 00:28:08 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x51vE-84-oKr; Tue, 30 Jan 2024 00:28:06 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4D967E9D8A; Tue, 30 Jan 2024 00:28:06 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Jan 2024 00:27:53 +0100 Message-Id: <20240129232755.9622-3-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240129232755.9622-1-cus@passwd.hu> References: <20240129232755.9622-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] avutil/channel_layout: add av_channel_layout_from_custom() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: d5t1uUO+chTS Signed-off-by: Marton Balint --- doc/APIchanges | 3 +++ libavutil/channel_layout.c | 20 ++++++++++++++++++++ libavutil/channel_layout.h | 13 +++++++++++++ libavutil/version.h | 4 ++-- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index e477ed78e0..8e8498f803 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2024-02-xx - xxxxxxxxxx - lavu 58.37.100 - channel_layout.h + Add av_channel_layout_from_custom(). + 2023-11-xx - xxxxxxxxxx - lavfi 9.16.100 - buffersink.h buffersrc.h Add av_buffersink_get_colorspace and av_buffersink_get_color_range. Add AVBufferSrcParameters.color_space and AVBufferSrcParameters.color_range. diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index b59d798f29..0810d32bf6 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -398,6 +398,26 @@ int av_get_standard_channel_layout(unsigned index, uint64_t *layout, FF_ENABLE_DEPRECATION_WARNINGS #endif +int av_channel_layout_from_custom(AVChannelLayout *channel_layout, int nb_channels) +{ + AVChannelCustom *map; + + if (nb_channels <= 0) + return AVERROR(EINVAL); + + map = av_calloc(nb_channels, sizeof(*channel_layout->u.map)); + if (!map) + return AVERROR(ENOMEM); + for (int i = 0; i < nb_channels; i++) + map[i].id = AV_CHAN_UNKNOWN; + + channel_layout->order = AV_CHANNEL_ORDER_CUSTOM; + channel_layout->nb_channels = nb_channels; + channel_layout->u.map = map; + + return 0; +} + int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask) { diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index 8dc1a91401..37629ab5d2 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -617,6 +617,19 @@ void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_i */ enum AVChannel av_channel_from_string(const char *name); +/** + * Initialize a custom channel layout with the specified number of channels. + * The designation of all channels will be unknown. + * + * @param channel_layout the layout structure to be initialized + * @param nb_channels the number of channels + * + * @return 0 on success + * AVERROR(EINVAL) if the number of channels <= 0 + * AVERROR(ENOMEM) if the channel map could not be allocated + */ +int av_channel_layout_from_custom(AVChannelLayout *channel_layout, int nb_channels); + /** * Initialize a native channel layout from a bitmask indicating which channels * are present. diff --git a/libavutil/version.h b/libavutil/version.h index 772c4e209c..3b38f8f5da 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 58 -#define LIBAVUTIL_VERSION_MINOR 36 -#define LIBAVUTIL_VERSION_MICRO 101 +#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \