Commit 3e336076 authored by liksonov's avatar liksonov
Browse files

Move prox mixing to the decoder.

parent c435e0f4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@
    <ClCompile Include="..\lib_dec\ivas_out_setup_conversion.c" />
    <ClCompile Include="..\lib_dec\ivas_pca_dec.c" />
    <ClCompile Include="..\lib_dec\ivas_post_proc.c" />
    <ClCompile Include="..\lib_dec\ivas_prox_mix.c" />
    <ClCompile Include="..\lib_dec\ivas_range_uni_dec.c" />
    <ClCompile Include="..\lib_dec\ivas_render_config.c" />
    <ClCompile Include="..\lib_dec\ivas_reverb.c" />
@@ -392,6 +393,7 @@
    <ClCompile Include="..\lib_dec\ivas_sns_dec.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_dec\ivas_prox_mix.h" />
    <ClInclude Include="..\lib_dec\ivas_rom_binauralRenderer.h" />
    <ClInclude Include="..\lib_dec\ivas_rom_binaural_crend_head.h" />
    <ClInclude Include="..\lib_dec\ivas_rom_dec.h" />
+6 −0
Original line number Diff line number Diff line
@@ -581,6 +581,9 @@
    <ClCompile Include="..\lib_dec\ivas_spar_md_dec.c">
      <Filter>dec_ivas_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_dec\ivas_prox_mix.c">
      <Filter>dec_ivas_c</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_dec\jbm_jb4_inputbuffer.h">
@@ -629,6 +632,9 @@
    <ClInclude Include="..\lib_dec\ivas_rom_binaural_crend_head.h">
      <Filter>dec_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_dec\ivas_prox_mix.h">
      <Filter>dec_h</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <Filter Include="dec_all_c">
+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@

#ifdef DEBUGGING

#define DEBUG_PROX_MIX_INFO

/*#define MEM_COUNT_DETAILS*/                   /* RAM counting tool: print per sub-structure details */

/*#define DEBUG_MODE_INFO*/                     /* output most important parameters to the subdirectory "res/" */
@@ -132,6 +134,8 @@

/* ################# Start DEVELOPMENT switches ######################## */

/* #define ENABLE_PROX_BASED_MIXING */                  /* Enable proximity-based mixing */

#define BASOP_NOGLOB                                    /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */
#define BITSTREAM_INDICES_MEMORY                        /* Don't count memory for bitstream Indice at the encoder - it is a temporary solution for development only */

+52 −0
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#ifdef ENABLE_PROX_BASED_MIXING
#include "ivas_prox_mix.h"
#endif /* ENABLE_PROX_BASED_MIXING */
#include "wmops.h"


@@ -50,6 +53,10 @@
#define DOWNMIX_MAX_GAIN                      4.0f  /* Maximum allowed gain  */
#define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4

#ifdef ENABLE_PROX_BASED_MIXING
#define PROXIMITY_USER_ID ( 0 )
const uint8_t bitstream[] = { 0x00, 0x01, 0x80, 0x02, 0x80 };
#endif /* ENABLE_PROX_BASED_MIXING */

/*-------------------------------------------------------------------------
 * ivas_mono_dmx_renderer_open()
@@ -73,6 +80,22 @@ ivas_error ivas_mono_dmx_renderer_open(

    st_ivas->hMonoDmxRenderer = hDownmix;

#ifdef ENABLE_PROX_BASED_MIXING
    set_zero( hDownmix->powvec, MAX_INPUT_CHANNELS );
    set_zero( hDownmix->Smixer, MAX_INPUT_CHANNELS );
    set_s( hDownmix->userLoc, 0, MAX_INPUT_CHANNELS );

    /* using bitstream information fill in the location in the userLoc vector */
    get_users_locations( bitstream, sizeof( bitstream ), hDownmix->userLoc );

#ifdef DEBUG_PROX_MIX_INFO
    for(int i = 0 ; i < MAX_INPUT_CHANNELS; i++)
    {
        printf("\n  i = %d, userLoc = %d \n", i, hDownmix->userLoc[i] );
    }
#endif /* DEBUG_PROX_MIX_INFO */
#endif /* ENABLE_PROX_BASED_MIXING */

    return IVAS_ERR_OK;
}

@@ -97,11 +120,36 @@ void ivas_mono_downmix_render_passive(
    hDownmix = st_ivas->hMonoDmxRenderer;
    set_zero( proto_signal, output_frame );

#ifdef ENABLE_PROX_BASED_MIXING
    /* get the mixing matrix.. */
    get_prox_downmix_mixer( ( int16_t )PROXIMITY_USER_ID, hDownmix->Smixer, hDownmix->userLoc, numInputChannels, output_f, output_frame, hDownmix->powvec );

#ifdef DEBUG_PROX_MIX_INFO
    printf("\n\n  hDownmix->Smixer  =  ");
    for(int i = 0; i < numInputChannels; i++)
        printf( "%.8f   ", hDownmix->Smixer[i] );
    
    printf("\n  hDownmix->powvec  =  ");
    for(int i = 0; i < numInputChannels; i++)
        printf( "%.6e   ", hDownmix->powvec[i] );

    printf("\n");
#endif /* DEBUG_PROX_MIX_INFO */

    /* Compute the Proto Signal */
    for ( i = 0; i < numInputChannels; i++ )
    {
        float temp[L_FRAME48k];
        v_multc( output_f[i], hDownmix->Smixer[i], temp, output_frame );
        v_add( temp, proto_signal, proto_signal, output_frame );
    }
#else /* ENABLE_PROX_BASED_MIXING */
    /* Compute the Proto Signal */
    for ( i = 0; i < numInputChannels; i++ )
    {
        v_add( output_f[i], proto_signal, proto_signal, output_frame );
    }
#endif /* ENABLE_PROX_BASED_MIXING */

    /* compute the input energy, proto energy after smoothing */
    hDownmix->inputEnergy[0] *= DOWNMIX_ALPHA;
@@ -111,7 +159,11 @@ void ivas_mono_downmix_render_passive(
        hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i];
        for ( j = 0; j < numInputChannels; j++ )
        {
#ifndef ENABLE_PROX_BASED_MIXING
            hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] );
#else
            hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] * hDownmix->Smixer[j] * hDownmix->Smixer[j] );
#endif
        }
    }

+5 −5
Original line number Diff line number Diff line
@@ -80,8 +80,8 @@ static float get_block_power( float *vec, int32_t frame_len );
  *
  *-----------------------------------------------------------------------------------------*/

ivas_result_t get_users_locations( 
    uint8_t *bitstream, 
ivas_error get_users_locations( 
    const uint8_t *bitstream, 
    int32_t len, 
    int16_t *userLoc )
{
@@ -103,11 +103,11 @@ ivas_result_t get_users_locations(
        }
    }

    return IVAS_SUCCESS;
    return IVAS_ERR_OK;
}


ivas_result_t get_prox_downmix_mixer( 
ivas_error get_prox_downmix_mixer( 
    int16_t userID, 
    float *sMixer, 
    int16_t *userLoc, 
@@ -209,7 +209,7 @@ ivas_result_t get_prox_downmix_mixer(
    }
    free( pow );

    return IVAS_SUCCESS;
    return IVAS_ERR_OK;
}


Loading