From 20af68b63a49e41b0b4233833230eff32778ad20 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sat, 26 Oct 2024 12:13:00 -0300 Subject: [PATCH] avutil/channel_layout: add Binaural channels and layout Signed-off-by: James Almer --- doc/APIchanges | 5 +++++ doc/utils.texi | 2 ++ libavutil/channel_layout.c | 3 +++ libavutil/channel_layout.h | 7 +++++++ libavutil/version.h | 2 +- tests/ref/fate/channel_layout | 1 + 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6f21a952dd..15606cafac 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,11 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-11-13 - xxxxxxxxxx - lavu 59.47.100 - channel_layout.h + Add AV_CHAN_BINAURAL_LEFT, AV_CHAN_BINAURAL_RIGHT + Add AV_CH_BINAURAL_LEFT, AV_CH_BINAURAL_RIGHT + Add AV_CH_LAYOUT_BINAURAL, AV_CHANNEL_LAYOUT_BINAURAL + 2024-10-26 - xxxxxxxxxx - lavu 59.46.100 - pixfmt.h Add AV_PIX_FMT_XV48. diff --git a/doc/utils.texi b/doc/utils.texi index 9968725d2a..eb5ccc8355 100644 --- a/doc/utils.texi +++ b/doc/utils.texi @@ -733,6 +733,8 @@ FL+FR+FC+LFE+BL+BR+SL+SR+TFL+TFR+TBC+LFE2 FL+FR+FC+LFE+BL+BR+FLC+FRC+SL+SR+TFL+TFR+TBL+TBR @item hexadecagonal FL+FR+FC+BL+BR+BC+SL+SR+WL+WR+TBL+TBR+TBC+TFC+TFL+TFR +@item binaural +BIL+BIR @item downmix DL+DR @item 22.2 diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 2d6963b6df..dd97e167c7 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -79,6 +79,8 @@ static const struct channel_name channel_names[] = { [AV_CHAN_SIDE_SURROUND_RIGHT ] = { "SSR", "side surround right" }, [AV_CHAN_TOP_SURROUND_LEFT ] = { "TTL", "top surround left" }, [AV_CHAN_TOP_SURROUND_RIGHT ] = { "TTR", "top surround right" }, + [AV_CHAN_BINAURAL_LEFT ] = { "BIL", "binaural left" }, + [AV_CHAN_BINAURAL_RIGHT ] = { "BIR", "binaural right" }, }; void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) @@ -220,6 +222,7 @@ static const struct channel_layout_name channel_layout_map[] = { { "7.2.3", AV_CHANNEL_LAYOUT_7POINT2POINT3 }, { "9.1.4", AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK }, { "hexadecagonal", AV_CHANNEL_LAYOUT_HEXADECAGONAL }, + { "binaural", AV_CHANNEL_LAYOUT_BINAURAL }, { "downmix", AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, }, { "22.2", AV_CHANNEL_LAYOUT_22POINT2, }, }; diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index 3a96c2d9b8..23fbc90606 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -84,6 +84,9 @@ enum AVChannel { AV_CHAN_TOP_SURROUND_LEFT, ///< +110 degrees, Lvs, TpLS AV_CHAN_TOP_SURROUND_RIGHT, ///< -110 degrees, Rvs, TpRS + AV_CHAN_BINAURAL_LEFT = 61, + AV_CHAN_BINAURAL_RIGHT, + /** Channel is empty can be safely skipped. */ AV_CHAN_UNUSED = 0x200, @@ -203,6 +206,8 @@ enum AVChannelOrder { #define AV_CH_SIDE_SURROUND_RIGHT (1ULL << AV_CHAN_SIDE_SURROUND_RIGHT ) #define AV_CH_TOP_SURROUND_LEFT (1ULL << AV_CHAN_TOP_SURROUND_LEFT ) #define AV_CH_TOP_SURROUND_RIGHT (1ULL << AV_CHAN_TOP_SURROUND_RIGHT ) +#define AV_CH_BINAURAL_LEFT (1ULL << AV_CHAN_BINAURAL_LEFT ) +#define AV_CH_BINAURAL_RIGHT (1ULL << AV_CHAN_BINAURAL_RIGHT ) /** * @} @@ -244,6 +249,7 @@ enum AVChannelOrder { #define AV_CH_LAYOUT_7POINT2POINT3 (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_CENTER|AV_CH_LOW_FREQUENCY_2) #define AV_CH_LAYOUT_9POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) #define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) +#define AV_CH_LAYOUT_BINAURAL (AV_CH_BINAURAL_LEFT|AV_CH_BINAURAL_RIGHT) #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) #define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT) @@ -418,6 +424,7 @@ typedef struct AVChannelLayout { #define AV_CHANNEL_LAYOUT_7POINT2POINT3 AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT2POINT3) #define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(14, AV_CH_LAYOUT_9POINT1POINT4_BACK) #define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL) +#define AV_CHANNEL_LAYOUT_BINAURAL AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_BINAURAL) #define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO_DOWNMIX) #define AV_CHANNEL_LAYOUT_22POINT2 AV_CHANNEL_LAYOUT_MASK(24, AV_CH_LAYOUT_22POINT2) diff --git a/libavutil/version.h b/libavutil/version.h index 84a7cb1c02..c1878a49ad 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 46 +#define LIBAVUTIL_VERSION_MINOR 47 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout index 0bcfefce3b..0e3d6914bc 100644 --- a/tests/ref/fate/channel_layout +++ b/tests/ref/fate/channel_layout @@ -34,6 +34,7 @@ cube FL+FR+BL+BR+TFL+TFR+TBL+TBR 7.2.3 FL+FR+FC+LFE+BL+BR+SL+SR+TFL+TFR+TBC+LFE2 9.1.4 FL+FR+FC+LFE+BL+BR+FLC+FRC+SL+SR+TFL+TFR+TBL+TBR hexadecagonal FL+FR+FC+BL+BR+BC+SL+SR+TFL+TFC+TFR+TBL+TBC+TBR+WL+WR +binaural BIL+BIR downmix DL+DR 22.2 FL+FR+FC+LFE+BL+BR+FLC+FRC+BC+SL+SR+TC+TFL+TFC+TFR+TBL+TBC+TBR+LFE2+TSL+TSR+BFC+BFL+BFR