[FFmpeg-devel] [PATCH] avutil/avcodec: expanded on channel configurations for spatial audio

Dylan Marcus dylan at mach1studios.com
Thu Jan 16 18:34:12 EET 2020


> On Jan 16, 2020, at 5:06 AM, Paul B Mahol <onemda at gmail.com> wrote:
> 
> Wait for custom channel layouts.

is there any information on this? I would love to review this as this is a constant requirement for a growing number of projects utilizing ffmpeg and would love to make sure this handles all use cases. 

> 
> On 1/16/20, Dylan Marcus <dylan at mach1studios.com> wrote:
>> ---
>> Changelog                  |  1 +
>> libavcodec/aacenc.h        | 16 ++++++++++++
>> libavutil/channel_layout.c |  8 ++++++
>> libavutil/channel_layout.h | 64
>> ++++++++++++++++++++++++++--------------------
>> 4 files changed, 61 insertions(+), 28 deletions(-)
>> 
>> diff --git a/Changelog b/Changelog
>> index 2ccd2645fc..08918e95da 100644
>> --- a/Changelog
>> +++ b/Changelog
>> @@ -30,6 +30,7 @@ version <next>:
>> - MPEG-H 3D Audio support in mp4
>> - thistogram filter
>> - freezeframes filter
>> +- Support for Mach1 Spatial audio channel configurations
>> 
>> 
>> version 4.2:
>> diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
>> index 5a015ca92e..a0f99680ee 100644
>> --- a/libavcodec/aacenc.h
>> +++ b/libavcodec/aacenc.h
>> @@ -368,6 +368,22 @@ static const AACPCEInfo aac_pce_configs[] = {
>>         .config_map = { 10, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE,
>> TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_CPE, TYPE_SCE },
>>         .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
>> 15 },
>>     },
>> +    {
>> +        .layout = AV_CH_LAYOUT_MACH1SPATIAL_8,
>> +        .num_ele = { 4, 0, 4, 0 },
>> +        .pairing = { { 0 }, { 0 }, { 0 } },
>> +        .index = { { 0, 1, 4, 5 }, { 0 }, { 2, 3, 6, 7 } },
>> +        .config_map = { 8, TYPE_SCE, TYPE_SCE, TYPE_SCE, TYPE_SCE,
>> TYPE_SCE, TYPE_SCE, TYPE_SCE, TYPE_SCE },
>> +        .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
>> +    },
>> +    {
>> +        .layout = AV_CH_LAYOUT_MACH1SPATIAL_8_ST,
>> +        .num_ele = { 5, 0, 4, 0 },
>> +        .pairing = { { 0, 1 }, { 0 }, { 0 } },
>> +        .index = { {0, 1, 4, 5, 0 }, { 0 }, { 2, 3, 6, 7 } },
>> +        .config_map = { 9, TYPE_SCE, TYPE_SCE, TYPE_SCE, TYPE_SCE,
>> TYPE_SCE, TYPE_SCE, TYPE_SCE, TYPE_SCE, TYPE_CPE },
>> +        .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
>> +    },
>> };
>> 
>> /**
>> diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
>> index 3bd5ee29b7..37119fd023 100644
>> --- a/libavutil/channel_layout.c
>> +++ b/libavutil/channel_layout.c
>> @@ -62,6 +62,12 @@ static const struct channel_name channel_names[] = {
>>     [33] = { "SDL",       "surround direct left"  },
>>     [34] = { "SDR",       "surround direct right" },
>>     [35] = { "LFE2",      "low frequency 2"       },
>> +    [36] = { "BFL",       "bottom front left"     },
>> +    [37] = { "BFR",       "bottom front right"    },
>> +    [38] = { "BBL",       "bottom back left"      },
>> +    [39] = { "BBR",       "bottom back right"     },
>> +    [40] = { "STL",       "spatial stereo left"   },
>> +    [41] = { "STR",       "spatial stereo right"  },
>> };
>> 
>> static const char *get_channel_name(int channel_id)
>> @@ -104,6 +110,8 @@ static const struct {
>>     { "octagonal",   8,  AV_CH_LAYOUT_OCTAGONAL },
>>     { "hexadecagonal", 16, AV_CH_LAYOUT_HEXADECAGONAL },
>>     { "downmix",     2,  AV_CH_LAYOUT_STEREO_DOWNMIX, },
>> +    { "mach1spatial-8", 8, AV_CH_LAYOUT_MACH1SPATIAL_8 },
>> +    { "mach1spatial-8.2", 10, AV_CH_LAYOUT_MACH1SPATIAL_8_ST},
>> };
>> 
>> static uint64_t get_channel_layout_single(const char *name, int name_len)
>> diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
>> index 50bb8f03c5..5bb2415155 100644
>> --- a/libavutil/channel_layout.h
>> +++ b/libavutil/channel_layout.h
>> @@ -64,6 +64,10 @@
>> #define AV_CH_TOP_BACK_LEFT          0x00008000
>> #define AV_CH_TOP_BACK_CENTER        0x00010000
>> #define AV_CH_TOP_BACK_RIGHT         0x00020000
>> +#define AV_CH_BOTTOM_FRONT_LEFT      0x0000001000000000ULL
>> +#define AV_CH_BOTTOM_FRONT_RIGHT     0x0000002000000000ULL
>> +#define AV_CH_BOTTOM_BACK_LEFT       0x0000004000000000ULL
>> +#define AV_CH_BOTTOM_BACK_RIGHT      0x0000008000000000ULL
>> #define AV_CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
>> #define AV_CH_STEREO_RIGHT           0x40000000  ///< See
>> AV_CH_STEREO_LEFT.
>> #define AV_CH_WIDE_LEFT              0x0000000080000000ULL
>> @@ -71,6 +75,8 @@
>> #define AV_CH_SURROUND_DIRECT_LEFT   0x0000000200000000ULL
>> #define AV_CH_SURROUND_DIRECT_RIGHT  0x0000000400000000ULL
>> #define AV_CH_LOW_FREQUENCY_2        0x0000000800000000ULL
>> +#define AV_CH_SPATIAL_STEREO_LEFT    0x0000010000000000ULL  ///< Non
>> diegetic stereo for spatial channel formats
>> +#define AV_CH_SPATIAL_STEREO_RIGHT   0x0000020000000000ULL  ///< See
>> AV_CH_SPATIAL_STEREO_LEFT
>> 
>> /** Channel mask value used for AVCodecContext.request_channel_layout
>>     to indicate that the user requests the channel order of the decoder
>> output
>> @@ -82,34 +88,36 @@
>>  * @defgroup channel_mask_c Audio channel layouts
>>  * @{
>>  * */
>> -#define AV_CH_LAYOUT_MONO              (AV_CH_FRONT_CENTER)
>> -#define AV_CH_LAYOUT_STEREO            (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
>> -#define AV_CH_LAYOUT_2POINT1
>> (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
>> -#define AV_CH_LAYOUT_2_1
>> (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
>> -#define AV_CH_LAYOUT_SURROUND
>> (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
>> -#define AV_CH_LAYOUT_3POINT1
>> (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
>> -#define AV_CH_LAYOUT_4POINT0
>> (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
>> -#define AV_CH_LAYOUT_4POINT1
>> (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
>> -#define AV_CH_LAYOUT_2_2
>> (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
>> -#define AV_CH_LAYOUT_QUAD
>> (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> -#define AV_CH_LAYOUT_5POINT0
>> (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
>> -#define AV_CH_LAYOUT_5POINT1
>> (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
>> -#define AV_CH_LAYOUT_5POINT0_BACK
>> (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> -#define AV_CH_LAYOUT_5POINT1_BACK
>> (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
>> -#define AV_CH_LAYOUT_6POINT0
>> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
>> -#define AV_CH_LAYOUT_6POINT0_FRONT
>> (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> -#define AV_CH_LAYOUT_HEXAGONAL
>> (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
>> -#define AV_CH_LAYOUT_6POINT1
>> (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
>> -#define AV_CH_LAYOUT_6POINT1_BACK
>> (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
>> -#define AV_CH_LAYOUT_6POINT1_FRONT
>> (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
>> -#define AV_CH_LAYOUT_7POINT0
>> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> -#define AV_CH_LAYOUT_7POINT0_FRONT
>> (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> -#define AV_CH_LAYOUT_7POINT1
>> (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> -#define AV_CH_LAYOUT_7POINT1_WIDE
>> (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> -#define AV_CH_LAYOUT_7POINT1_WIDE_BACK
>> (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> -#define AV_CH_LAYOUT_OCTAGONAL
>> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
>> -#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_STEREO_DOWNMIX
>> (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
>> +#define AV_CH_LAYOUT_MONO               (AV_CH_FRONT_CENTER)
>> +#define AV_CH_LAYOUT_STEREO
>> (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
>> +#define AV_CH_LAYOUT_2POINT1
>> (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
>> +#define AV_CH_LAYOUT_2_1
>> (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
>> +#define AV_CH_LAYOUT_SURROUND
>> (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
>> +#define AV_CH_LAYOUT_3POINT1
>> (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
>> +#define AV_CH_LAYOUT_4POINT0
>> (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
>> +#define AV_CH_LAYOUT_4POINT1
>> (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
>> +#define AV_CH_LAYOUT_2_2
>> (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
>> +#define AV_CH_LAYOUT_QUAD
>> (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> +#define AV_CH_LAYOUT_5POINT0
>> (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
>> +#define AV_CH_LAYOUT_5POINT1
>> (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
>> +#define AV_CH_LAYOUT_5POINT0_BACK
>> (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> +#define AV_CH_LAYOUT_5POINT1_BACK
>> (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
>> +#define AV_CH_LAYOUT_6POINT0
>> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
>> +#define AV_CH_LAYOUT_6POINT0_FRONT
>> (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> +#define AV_CH_LAYOUT_HEXAGONAL
>> (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
>> +#define AV_CH_LAYOUT_6POINT1
>> (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
>> +#define AV_CH_LAYOUT_6POINT1_BACK
>> (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
>> +#define AV_CH_LAYOUT_6POINT1_FRONT
>> (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
>> +#define AV_CH_LAYOUT_7POINT0
>> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> +#define AV_CH_LAYOUT_7POINT0_FRONT
>> (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> +#define AV_CH_LAYOUT_7POINT1
>> (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
>> +#define AV_CH_LAYOUT_7POINT1_WIDE
>> (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> +#define AV_CH_LAYOUT_7POINT1_WIDE_BACK
>> (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
>> +#define AV_CH_LAYOUT_OCTAGONAL
>> (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
>> +#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_STEREO_DOWNMIX
>> (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
>> +#define AV_CH_LAYOUT_MACH1SPATIAL_8
>> (AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT|AV_CH_BOTTOM_BACK_LEFT|AV_CH_BOTTOM_BACK_RIGHT)
>> +#define AV_CH_LAYOUT_MACH1SPATIAL_8_ST
>> (AV_CH_LAYOUT_MACH1SPATIAL_8|AV_CH_SPATIAL_STEREO_LEFT|AV_CH_SPATIAL_STEREO_RIGHT)
>> 
>> enum AVMatrixEncoding {
>>     AV_MATRIX_ENCODING_NONE,
>> --
>> 2.16.3
>> 
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list