Commit 3447d9da authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

add conversion functions for ambisonics input/output

parent cf494821
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@
    </Lib>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClCompile Include="..\lib_util\ambi_cenvert.c" />
    <ClCompile Include="..\lib_util\audio_file_reader.c" />
    <ClCompile Include="..\lib_util\audio_file_writer.c" />
    <ClCompile Include="..\lib_util\bitstream_reader.c" />
@@ -126,6 +127,7 @@
    <ClCompile Include="..\lib_util\tsm_scale_file_reader.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_util\ambi_convert.h" />
    <ClInclude Include="..\lib_util\audio_file_reader.h" />
    <ClInclude Include="..\lib_util\audio_file_writer.h" />
    <ClInclude Include="..\lib_util\bitstream_reader.h" />
+90 −0
Original line number Diff line number Diff line
/******************************************************************************************************

   (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository. All Rights Reserved.

   This software is protected by copyright law and by international treaties.
   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository retain full ownership rights in their respective contributions in
   the software. This notice grants no license of any kind, including but not limited to patent
   license, nor is any license granted by implication, estoppel or otherwise.

   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
   contributions.

   This software is provided "AS IS", without any express or implied warranties. The software is in the
   development stage. It is intended exclusively for experts who have experience with such software and
   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
   and fitness for a particular purpose are hereby disclaimed and excluded.

   Any dispute, controversy or claim arising under or in relation to providing this software shall be
   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
   the United Nations Convention on Contracts on the International Sales of Goods.

*******************************************************************************************************/

#include <stdint.h>
#include "ivas_cnst.h"
#include "ambi_convert.h"

int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format )
{
    assert( order <= 3 );

    if ( in_format == AMBI_FMT_ACN_SN3D )
    {
        if ( out_format == AMBI_FMT_ACN_N3D )
        {
            renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_N3D );
            reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_FM );
        }
        else if ( out_format == AMBI_FMT_FM_MAXN )
        {
            renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_MAXN );
            reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_FM );
        }
        else if ( out_format == AMBI_FMT_SID_SN3D )
        {
            reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID );
        }
        else if ( out_format == AMBI_FMT_SID_N3D )
        {
            renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_N3D );
            reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID );
        }
        else
        {
            assert( 0 && "Unsupported conversion" );
		}
	}
    else if ( in_format == AMBI_FMT_ACN_N3D )
    {
    }
    else
    {
        assert( 0 && "Conversion only supported to and from ACN-SN3D" );
    }

    return 0;
}

int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format )
{
    int16_t nchan = ( order + 1 ) * ( order + 1 );

    return 0;
}

int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format )
{
    int16_t nchan = ( order + 1 ) * ( order + 1 );

    return 0;
}
+66 −0
Original line number Diff line number Diff line
/******************************************************************************************************

   (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository. All Rights Reserved.

   This software is protected by copyright law and by international treaties.
   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository retain full ownership rights in their respective contributions in
   the software. This notice grants no license of any kind, including but not limited to patent
   license, nor is any license granted by implication, estoppel or otherwise.

   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
   contributions.

   This software is provided "AS IS", without any express or implied warranties. The software is in the
   development stage. It is intended exclusively for experts who have experience with such software and
   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
   and fitness for a particular purpose are hereby disclaimed and excluded.

   Any dispute, controversy or claim arising under or in relation to providing this software shall be
   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
   the United Nations Convention on Contracts on the International Sales of Goods.

*******************************************************************************************************/

#include <stdint.h>

typedef enum
{
    AMBI_FMT_ACN_SN3D = 0,
    AMBI_FMT_ACN_N3D,

    AMBI_FMT_FM_MAXN,

    AMBI_FMT_SID_SN3D,
    AMBI_FMT_SID_N3D
} AMBI_FMT;

typedef enum
{
    AMBI_NORM_SN3D = 0,
    AMBI_NORM_N3D = 1,
    AMBI_NORM_MAXN = 2
} AMBI_CHANNEL_NORM;

typedef enum
{
	AMBI_CHANNEL_ORDER_ACN = 0,
    AMBI_CHANNEL_ORDER_FM = 1,
    AMBI_CHANNEL_ORDER_SID = 2
} AMBI_CHANNEL_ORDER;

int16_t convert_ambi_format(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format);

int16_t renormalize_channels(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format);

int16_t reorder_channels(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format);