Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Marton Balint <cus@passwd.hu>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/7] avutil/channel_layout: add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
Date: Sat, 16 Mar 2024 09:34:13 +0100 (CET)
Message-ID: <76b7efc1-ea5a-efc1-fe50-5e536dfa20d2@passwd.hu> (raw)
In-Reply-To: <20240309215414.26699-1-cus@passwd.hu>



On Sat, 9 Mar 2024, Marton Balint wrote:

> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> doc/APIchanges             |  3 +++
> libavutil/channel_layout.c | 30 ++++++++++++++++++++++++++++++
> libavutil/channel_layout.h |  7 +++++++
> libavutil/version.h        |  2 +-
> 4 files changed, 41 insertions(+), 1 deletion(-)

Will apply the series.

Regards,
Marton

>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index cf58c8c5f0..a44c8e4f10 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
>
> API changes, most recent first:
>
> +2024-03-xx - xxxxxxxxxx - lavu 59.2.100 - channel_layout.h
> +  Add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL.
> +
> 2024-03-08 - xxxxxxxxxx - lavc 61.1.100 - avcodec.h
>   Add AVCodecContext.[nb_]side_data_prefer_packet.
>
> diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
> index 8c1b3362f7..d3abb2dc42 100644
> --- a/libavutil/channel_layout.c
> +++ b/libavutil/channel_layout.c
> @@ -553,6 +553,33 @@ static int ambisonic_order(const AVChannelLayout *channel_layout)
>     return order;
> }
>
> +static enum AVChannelOrder canonical_order(AVChannelLayout *channel_layout)
> +{
> +    int has_known_channel = 0;
> +    int order;
> +
> +    if (channel_layout->order != AV_CHANNEL_ORDER_CUSTOM)
> +        return channel_layout->order;
> +
> +    if (has_channel_names(channel_layout))
> +        return AV_CHANNEL_ORDER_CUSTOM;
> +
> +    for (int i = 0; i < channel_layout->nb_channels && !has_known_channel; i++)
> +        if (channel_layout->u.map[i].id != AV_CHAN_UNKNOWN)
> +            has_known_channel = 1;
> +    if (!has_known_channel)
> +        return AV_CHANNEL_ORDER_UNSPEC;
> +
> +    if (masked_description(channel_layout, 0) > 0)
> +        return AV_CHANNEL_ORDER_NATIVE;
> +
> +    order = ambisonic_order(channel_layout);
> +    if (order >= 0 && masked_description(channel_layout, (order + 1) * (order + 1)) >= 0)
> +        return AV_CHANNEL_ORDER_AMBISONIC;
> +
> +    return AV_CHANNEL_ORDER_CUSTOM;
> +}
> +
> /**
>  * If the custom layout is n-th order standard-order ambisonic, with optional
>  * extra non-diegetic channels at the end, write its string description in bp.
> @@ -892,6 +919,9 @@ int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrde
>     if (!av_channel_layout_check(channel_layout))
>         return AVERROR(EINVAL);
>
> +    if (flags & AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL)
> +        order = canonical_order(channel_layout);
> +
>     if (channel_layout->order == order)
>         return 0;
>
> diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
> index 10ffe74468..a1e9b08064 100644
> --- a/libavutil/channel_layout.h
> +++ b/libavutil/channel_layout.h
> @@ -680,6 +680,13 @@ int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout
>  */
> #define AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS (1 << 0)
>
> +/**
> + * The specified retype target order is ignored and the simplest possible
> + * (canonical) order is used for which the input layout can be losslessy
> + * represented.
> + */
> +#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL (1 << 1)
> +
> /**
>  * Change the AVChannelOrder of a channel layout.
>  *
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 09f8cdc292..57cad02ec0 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>  */
>
> #define LIBAVUTIL_VERSION_MAJOR  59
> -#define LIBAVUTIL_VERSION_MINOR   1
> +#define LIBAVUTIL_VERSION_MINOR   2
> #define LIBAVUTIL_VERSION_MICRO 100
>
> #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> -- 
> 2.35.3
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

      parent reply	other threads:[~2024-03-16  8:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09 21:54 Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 2/7] avformat/mov_chan: simplify channel layout canonicalization Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 3/7] avutil/tests/channel_layout: make printing results part of the tests Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 4/7] avutil/tests/channel_layout: add some av_channel_from_string and av_channel_layout_from_string tests Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 5/7] avutil/channel_layout: factorize parsing list of channel names Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 6/7] avutil/channel_layout: fix some (un)initialization issues in av_channel_layout_from_string() Marton Balint
2024-03-09 21:54 ` [FFmpeg-devel] [PATCH 7/7] avutil/channel_layout: add specific text versions for unknown and unused channels Marton Balint
2024-03-16  8:34 ` Marton Balint [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=76b7efc1-ea5a-efc1-fe50-5e536dfa20d2@passwd.hu \
    --to=cus@passwd.hu \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git