Commit 6f3ffe53 authored by Jan Kiene's avatar Jan Kiene
Browse files

fix incorrect port in one file + add forgotten file

parent dbcc7fe8
Loading
Loading
Loading
Loading
Loading
+288 −0
Original line number Diff line number Diff line
/******************************************************************************************************

   (C) 2022-2025 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 <assert.h>
#include <stdlib.h>
#include "ivas_error_utils.h"
#include "ivas_prot_rend.h"
#include "options.h"
#include "wmc_auto.h"


/*-----------------------------------------------------------------------*
 * Local function prototypes
 *-----------------------------------------------------------------------*/

static uint32_t ivas_td_ringbuf_total_size(
    TD_RINGBUF_HANDLE h )
{
    if ( h->is_full )
    {
        return h->capacity;
    }

    if ( h->read_pos <= h->write_pos )
    {
        return h->write_pos - h->read_pos;
    }
    /* else wrap around */
    return h->write_pos + h->capacity - h->read_pos;
}


static int16_t ivas_td_ringbuf_has_space_for_num_samples(
    TD_RINGBUF_HANDLE h,
    const uint32_t num_samples )
{
    return (int16_t) ( ivas_td_ringbuf_total_size( h ) + num_samples <= h->capacity );
}


/*-----------------------------------------------------------------------*
 * Global function definitions
 *-----------------------------------------------------------------------*/

/*---------------------------------------------------------------------*
 * ivas_TD_RINGBUF_Open()
 *
 * Allocate a ring buffer for TD data with the given capacity of TD samples per channel.
 *
 * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise.
 *---------------------------------------------------------------------*/

ivas_error ivas_TD_RINGBUF_Open(
    TD_RINGBUF_HANDLE *ph,               /* i/o: Ring buffer handle                     */
    const uint32_t capacity_per_channel, /* i  : Number of samples stored per channel   */
    const uint16_t num_channels          /* i  : Number of channels                     */
)
{
    TD_RINGBUF_HANDLE h;
    uint32_t capacity;

    capacity = capacity_per_channel * num_channels;

    h = malloc( sizeof( TD_RINGBUF_DATA ) );
    if ( h == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" );
    }
    h->data = NULL;
    h->capacity = 0;
    h->num_channels = num_channels;
    h->write_pos = 0;
    h->read_pos = 0;
    h->is_full = 0;
    *ph = h;

    h->data = malloc( capacity * sizeof( float ) );
    if ( h->data == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" );
    }
    h->capacity = capacity;

    return IVAS_ERR_OK;
}


/*---------------------------------------------------------------------*
 * ivas_TD_RINGBUF_Close()
 *
 * Dellocate TD ring buffer. The given handle will be set to NULL.

 *---------------------------------------------------------------------*/

void ivas_TD_RINGBUF_Close(
    TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */
)
{
    TD_RINGBUF_HANDLE h;

    if ( ph == NULL )
    {
        return;
    }
    h = *ph;

    if ( h == NULL )
    {
        return;
    }

    if ( h->data != NULL )
    {
        free( h->data );
    }

    free( h );
    *ph = NULL;

    return;
}


/*---------------------------------------------------------------------*
 * ivas_TD_RINGBUF_Push()
 *
 * Push samples onto the back of the TD ring buffer.
 * Returns total number of buffered samples (includes number of channels)
 *---------------------------------------------------------------------*/

void ivas_TD_RINGBUF_Push(
    TD_RINGBUF_HANDLE h,                   /* i/o: Ring buffer handle                       */
    const float *data,                     /* i  : Input data                               */
    const uint32_t num_samples_per_channel /* i  : Number of samples per channel to store   */
)
{
    uint32_t s;
    uint16_t c;

    assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) );

    for ( s = 0; s < num_samples_per_channel; ++s )
    {
        for ( c = 0; c < h->num_channels; ++c )
        {
            h->data[h->write_pos] = *( data + c * num_samples_per_channel + s );
            ++h->write_pos;

            if ( h->write_pos == h->capacity )
            {
                h->write_pos = 0;
            }
        }
    }

    if ( h->read_pos == h->write_pos )
    {
        h->is_full = 1;
    }

    return;
}


/*---------------------------------------------------------------------*
 * ivas_TD_RINGBUF_PushZeros()
 *
 * Push zero samples onto the back of the TD ring buffer.
 *---------------------------------------------------------------------*/

void ivas_TD_RINGBUF_PushZeros(
    TD_RINGBUF_HANDLE h,                   /* i/o: Ring buffer handle                   */
    const uint32_t num_samples_per_channel /* i  : Number of zeros per channel to store */
)
{
    uint32_t s;
    uint16_t c;

    assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) );
    if ( !num_samples_per_channel )
    {
        return;
    }

    for ( s = 0; s < num_samples_per_channel; ++s )
    {
        for ( c = 0; c < h->num_channels; ++c )
        {
            h->data[h->write_pos] = 0.f;
            ++h->write_pos;

            if ( h->write_pos == h->capacity )
            {
                h->write_pos = 0;
            }
        }
    }

    if ( h->read_pos == h->write_pos )
    {
        h->is_full = 1;
    }

    return;
}


/*---------------------------------------------------------------------*
 * ivas_TD_RINGBUF_Pop()
 *
 * Pop samples from the front of the TD ring buffer.
 *---------------------------------------------------------------------*/

void ivas_TD_RINGBUF_Pop(
    TD_RINGBUF_HANDLE h,                   /* i/o: Ring buffer handle                           */
    float *data,                           /* i  : Output data                                  */
    const uint32_t num_samples_per_channel /* i  : Number of samples per channel to retrieve    */
)
{
    uint32_t s;
    uint16_t c;

    assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels );

    for ( s = 0; s < num_samples_per_channel; ++s )
    {
        for ( c = 0; c < h->num_channels; ++c )
        {
            *( data + c * num_samples_per_channel + s ) = h->data[h->read_pos];
            ++h->read_pos;

            if ( h->read_pos == h->capacity )
            {
                h->read_pos = 0;
            }
        }
    }

    if ( h->is_full )
    {
        h->is_full = 0;
    }

    return;
}


/*---------------------------------------------------------------------*
 * ivas_TD_RINGBUF_Size()
 *
 * Returns number of buffered samples per channel.
 *---------------------------------------------------------------------*/

uint32_t ivas_TD_RINGBUF_Size(
    const TD_RINGBUF_HANDLE h /* i  : Ring buffer handle */
)
{
    return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels;
}
+1 −5
Original line number Diff line number Diff line
@@ -3681,11 +3681,7 @@ static int16_t getCldfbRendFlag(
            numSbaInputs += ( hIvasRend->inputsSba[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ? 0 : 1;
        }

        if ( numIsmInputs > 0 || numMcInputs > 0 )
        {
            isCldfbRend = 0;
        }
        else if ( ( numMasaInputs > 0 ) || ( numSbaInputs > 0 && hIvasRend->hRendererConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) )
        if ( ( numMasaInputs > 0 ) || ( numSbaInputs > 0 && hIvasRend->hRendererConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) )
        {
            isCldfbRend = 1;
        }